头文件带和不带.h的区别

所有C++标准库的头文件都是没有.h结尾的。这么做是为了区分,C标准库的头文件和C++标准库的头文件。比如最具代表性的:

#include <string.h>     // C 标准库头文件,包含 strlen,memset 等函数
#include <string>       // C++ 标准库头文件,包含 std::string 类

此外对于所有C标准库头文件,如果你是在C++项目中引用,你应该使用#include

猜你喜欢

转载自www.cnblogs.com/narjaja/p/10041348.html