头文件
- only declarations are allowed to be in .h(.h里放声明,不放定义)
- extern variables
- functions prototypes
- class/struct declaration
- #include
- #include’xx’: first search in the current directory,then the directories declared somewhere
- #include<xx.h>: search int the specified directories(系统头文件目录,linux下/usr/include/)
- #include
: same as #include<xx.h>
Standard header file structure(标准头文件结构)
1
2
3
4#ifndef HEADER_FLAG
#define HEADER_FLAG
//Type declaration here
#endif //HEADER_FLAGTips for header
- One class declaration per header file
- Associated with one source file in the same prefix of file name(一个头文件不能被include两次)
- The contents of a header file is surrrounded with #ifndef #define #endif