首先谈谈string的头文件
1、字符串
包装std的c头文件
2、string.h
旧的c头文件
3、cstring.h
旧c头文件的std版本。 请注意,这不是cstring头文件
详情请参照effectivec的第49条
除了cstring头文件之外
注:在VC9编译环境中
1、atlstr.h
在非MFC版本中,控制台程序使用此
afx.h、afxcoll.h都可以。 //项目-属性-通常设置为使用动态/静态(MFC )。
2、afx str.h//onlybeusedinmfcprojects。
需要MFC版本、MFC的dll或静态库的链接。 网上很多人说要包括afx.h,但afx.h包含的大多是CObject及其派生类,还有文件类、时间类、异常类、字符串类等。 (700多行的位置包含afxstr.h。 如果只需要cstring,则包含afxstr.h就足够了。
afx.h中的预处理
#ifdef_DLL
#ifndef_AFXDLL
# errorbuildingmfcapplicationwith/MD [ d ] (crtdll version ) requiresmfcshareddlversion.please # define _ afxdlordonotus
#endif
#endif
afxstr.h中的预处理
#ifndef_AFX
# errorafxstr.hcanonlybeusedinmfcprojects.useatlstr.h
#endif
请注意上面的#error。 这个头文件正在MFC项目中使用。