# :preprocess
declaration:声明,指function name
definition:定义,指function body
header file
# progma once:避免我们在同一个translation unit(即.cpp file) 里重复引用
header file(.h) 里放置所有函数的声明,便于在不同.cpp file 中调用其他.cpp file内的函数。
# ifndef _LOG_H
#define _LOG_H
中间写header file 的declaration
# endif
这一段preprocess是为了防止.h文件之间包含了其他.h文件里的声明,重复引用会报错。
以上两个preprocess等价
在这里顺便提到preprocessor 的两种符号
1、#include <iostream>
2、#include "log.h"
<>: 是拷贝iostream 到当前.cpp file
“”:内包含的文件是和当前.cpp file 路径相关的。
“”在任何情况下都可以使用,但是最好的情况是use it only for relative part, and use <> for compile part.