61)普通类的.h和.cpp分离

 1 //标头.h文件
 2 
 3 //这个是在C中这样写
 4 
 5 #ifndef HH_01//开始写小写  hh_01  然后选中这个  crtl+shift+u  就变成大写了
 6 #define HH_01
 7 
 8 
 9 #endif
10 
11 
12 
13 //在C++这样写,防止文件被包含
14 #pragma once
15 #include<string>
16 #include<iostream>
17 using namespace std;
18 
19 class person
20 {
21 public:
22     void hanshu();//这个叫没有实现,要是你在后面加一个大括号,那么就是实现了,只不过是空实现
23 
24 public:
25         string name;
26 };

标头.cpp文件

1 #include<标头.h>
2 
3 void person::hanshu()
4 {
5 //实现部分
6 }
原文地址:https://www.cnblogs.com/xiaoyoucai/p/8280250.html