1. 程式人生 > >標頭檔案帶和不帶.h的區別

標頭檔案帶和不帶.h的區別

所有C++標準庫的標頭檔案都是沒有.h結尾的。這麼做是為了區分,C標準庫的標頭檔案和C++標準庫的標頭檔案。比如最具代表性的:

#include <string.h>     // C 標準庫標頭檔案,包含 strlen,memset 等函式
#include <string>       // C++ 標準庫標頭檔案,包含 std::string 類

此外對於所有C標準庫標頭檔案,如果你是在C++專案中引用,你應該使用#include