CString與string的區別

2021-08-10 22:05:30 字數 435 閱讀 6920

cstring 是mfc或者atl中的實現,string是c++標準庫中的實現

string和cstring均是字串模板類,string為標準模板類(stl)定義的字串類,已經納入c++標準之中;

cstring(typedef cstringt> cstring)為visual c++中最常用的字串類,繼承自c******stringt類,主要應用在mfc和atl程式設計中,主要資料型別有char(應用於ansi),wchar_t(unicode),tchar(ansi與unicode均可);

char*為c程式設計中最常用的字串指標,一般以』\0』為結束標誌;

在mfc、atl中使用字串盡量使用cstring,畢竟都是微軟的孩子,各方面都比其它更有優勢,而在非微軟平台上或對移植性要求較高的場合推薦使用string,標準模板庫提供了那麼強大的泛型演算法,沒必要再自己去造車輪。

C String與string的區別

c 中同時存在string與string msdn中對string的說明 string is an alias for string in the net framework。string是string的別名而已,string是c 中的類,string是framework的類,c string 對映...

C string與String的區別

最近,正在簡單地學習c 的一些知識。c 是區分大小寫的,但是我卻發現c 中同時存在string與string,於是我很困惑,於是我上網搜尋了一下,於是我了解了一些小知識。msdn中對string的說明 string is an alias for string in the net framewor...

C String與string的區別

c string與string的區別 c 是區分大小寫的,但是我卻發現c 中同時存在string與string,於是我很困惑,於是我上網搜尋了一下,於是我了解了一些小知識。msdn中對string的說明 stringis analiasforstringin the net framework。st...