string標頭檔案與cstring標頭檔案

2021-05-24 05:19:56 字數 615 閱讀 8962

首先說string的標頭檔案

1、包裝了std的c++標頭檔案

2、舊的c標頭檔案

3、舊c標頭檔案的std版本,切記,這不是cstring的標頭檔案

詳見effective c++ 的第49條

再說cstring的標頭檔案

注:vc9編譯環境下

1、非mfc版本,控制台程式就用這個

2、mfc版本,需要鏈結mfc的dll或靜態庫。網上很多人說要包含,包含的東西就比較多了cobject及其派生類,還有檔案類、時間類、異常類、字串類等等(700多行的位置包含了afxstr.h),如果僅僅需要cstring的話,包含就夠了。

中的預處理

#ifdef _dll

#ifndef _afxdll

#endif

#endif

中的預處理

#ifndef _afx

#error afxstr.h can only be used in mfc projects.  use atlstr.h

#endif

注意上面的#error,大意就是這個標頭檔案是在mfc工程裡用的。要麼改用,要麼在專案->屬性->常規裡設定為在共享的dll中使用mfc.

string與string標頭檔案

先來段 我是在vs2012上實驗的 include stdafx.h include include include using namespace std int tmain int argc,tchar argv cout endl for rit mapstudent.rbegin rit m...

類實現string與string標頭檔案

首先宣告,我是乙個菜鳥。一下文章中湧現技術誤導情況蓋不負責 先來段 我是在vs2012上驗實的 include stdafx.h include include include using namespace std int tmain int argc,tchar argv cout endl f...

cstring與string標頭檔案與輸出

在使用了mfc庫的工程中cstring可以直接使用,在沒有使用mfc庫的工程中 先 右擊專案 屬性 配置屬性 常規,然後在右邊的 專案預設值 中的 mfc的使用 選項中選擇 在共享 dll 中使用 mfc 注意開啟屬性後,配置項的選擇要和當前使用的配置統一。然後再新增標頭檔案 include 可能v...