锘??xml version="1.0" encoding="utf-8" standalone="yes"?> { 銆銆榪欎釜瑙勫垯鍚屾牱閫傜敤浜庣被鐨勬垚鍛樼殑甯冨眬銆? }
聽聽聽 涓轟簡璁╃紪璇戝櫒浜х敓鏇村ソ鐨勪唬鐮?姣斿璇翠駭鐢?DNow! 鎴朣SE鎸囦護鐨勪唬鐮?錛屽繀欏葷‘瀹氭誕鐐瑰瀷鍙橀噺鍜岃〃杈懼紡鏄?float 鍨嬬殑銆傝鐗瑰埆娉ㄦ剰鐨勬槸錛屼互 "錛汧"錛?鎴?"錛沠"錛?涓哄悗緙錛堟瘮濡傦細3.14f錛夌殑嫻偣甯擱噺鎵嶆槸 float 鍨嬶紝鍚﹀垯榛樿鏄?double 鍨嬨備負浜嗛伩鍏?float 鍨嬪弬鏁拌嚜鍔ㄨ漿鍖栦負 double錛岃鍦ㄥ嚱鏁板0鏄庢椂浣跨敤 float銆?
2.浣跨敤32浣嶇殑鏁版嵁綾誨瀷
銆銆緙栬瘧鍣ㄦ湁寰堝縐嶏紝浣嗗畠浠兘鍖呭惈鐨勫吀鍨嬬殑32浣嶇被鍨嬫槸錛歩nt錛宻igned錛宻igned int錛寀nsigned錛寀nsigned int錛宭ong錛宻igned long錛宭ong int錛宻igned long int錛寀nsigned long錛寀nsigned long int銆傚敖閲忎嬌鐢?2浣嶇殑鏁版嵁綾誨瀷錛屽洜涓哄畠浠瘮16浣嶇殑鏁版嵁鐢氳嚦8浣嶇殑鏁版嵁鏇存湁鏁堢巼銆?
3.鏄庢櫤浣跨敤鏈夌鍙鋒暣鍨嬪彉閲?
銆銆鍦ㄥ緢澶氭儏鍐典笅錛屼綘闇瑕佽冭檻鏁村瀷鍙橀噺鏄湁絎﹀彿榪樻槸鏃犵鍙風被鍨嬬殑銆傛瘮濡傦紝淇濆瓨涓涓漢鐨勪綋閲嶆暟鎹椂涓嶅彲鑳藉嚭鐜拌礋鏁幫紝鎵浠ヤ笉闇瑕佷嬌鐢ㄦ湁絎﹀彿綾誨瀷銆備絾鏄紝濡傛灉鏄淇濆瓨娓╁害鏁版嵁錛屽氨蹇呴』浣跨敤鍒版湁絎﹀彿鐨勫彉閲忋?
銆銆鍦ㄨ澶氬湴鏂癸紝鑰冭檻鏄惁浣跨敤鏈夌鍙風殑鍙橀噺鏄繀瑕佺殑銆傚湪涓浜涙儏鍐典笅錛屾湁絎﹀彿鐨勮繍綆楁瘮杈冨揩錛涗絾鍦ㄤ竴浜涙儏鍐典笅鍗寸浉鍙嶃?
銆銆姣斿錛氭暣鍨嬪埌嫻偣杞寲鏃訛紝浣跨敤澶т簬16浣嶇殑鏈夌鍙鋒暣鍨嬫瘮杈冨揩銆傚洜涓簒86鏋勬灦涓彁渚涗簡浠庢湁絎﹀彿鏁村瀷杞寲鍒版誕鐐瑰瀷鐨勬寚浠わ紝浣嗘病鏈夋彁渚涗粠鏃犵鍙鋒暣鍨嬭漿鍖栧埌嫻偣鐨勬寚浠ゃ傜湅鐪嬬紪璇戝櫒浜х敓鐨勬眹緙栦唬鐮侊細
銆銆涓嶅ソ鐨勪唬鐮侊細
緙栬瘧鍓?聽聽聽聽聽緙栬瘧鍚?
double x錛浡犅犅犅爉ov [foo + 4], 0
unsigned int i錛浡犅犅爉ov eax, i
x = i錛浡犅犅犅犅爉ov [foo], eax
聽聽聽聽聽flid qword ptr [foo]
聽聽聽聽聽fstp qword ptr [x]
銆銆涓婇潰鐨勪唬鐮佹瘮杈冩參銆備笉浠呭洜涓烘寚浠ゆ暟鐩瘮杈冨錛岃屼笖鐢變簬鎸囦護涓嶈兘閰嶅閫犳垚鐨凢LID鎸囦護琚歡榪熸墽琛屻傛渶濂界敤浠ヤ笅浠g爜浠f浛錛?
聽聽聽 鎺ㄨ崘鐨勪唬鐮侊細
緙栬瘧鍓嵚犅犅犅犅犵紪璇戝悗
double x錛浡犅犅犅爁ild dword ptr
int i錛浡犅犅犅犅爁stp qword ptr [x]
x = i錛?
銆銆鍦ㄦ暣鏁拌繍綆椾腑璁$畻鍟嗗拰浣欐暟鏃訛紝浣跨敤鏃犵鍙風被鍨嬫瘮杈冨揩銆備互涓嬭繖孌靛吀鍨嬬殑浠g爜鏄紪璇戝櫒浜х敓鐨?2浣嶆暣鍨嬫暟闄や互4鐨勪唬鐮侊細
銆銆涓嶅ソ鐨勪唬鐮伮?
緙栬瘧鍓?聽聽聽聽聽緙栬瘧鍚?
int i錛浡犅犅犅犅爉ov eax, i
i = i / 4錛?聽聽聽聽cdq
聽聽聽聽聽and edx, 3
聽聽聽聽聽add eax, edx
聽聽聽聽聽sar eax, 2
聽聽聽聽聽mov i, eax
聽聽聽 鎺ㄨ崘鐨勪唬鐮?br />緙栬瘧鍓?聽聽聽聽聽緙栬瘧鍚?
unsigned int i錛?聽聽聽shr i, 2
i = i / 4錛?
銆鎬葷粨錛?br />銆鏃犵鍙風被鍨嬬敤浜庯細闄ゆ硶鍜屼綑鏁?寰幆璁℃暟,鏁扮粍涓嬫爣
聽 鏈夌鍙風被鍨嬬敤浜庯細鏁村瀷鍒版誕鐐圭殑杞寲
4.while VS. for
銆銆鍦ㄧ紪紼嬩腑錛屾垜浠父甯擱渶瑕佺敤鍒版棤闄愬驚鐜紝甯哥敤鐨勪袱縐嶆柟娉曟槸while (1) 鍜?for (錛涳紱)銆傝繖涓ょ鏂規硶鏁堟灉瀹屽叏涓鏍鳳紝浣嗛偅涓縐嶆洿濂藉憿錛熺劧鎴戜滑鐪嬬湅瀹冧滑緙栬瘧鍚庣殑浠g爜錛?
緙栬瘧鍓?聽聽聽聽聽緙栬瘧鍚?
while (1)錛?聽聽聽聽mov eax,1
聽聽聽聽聽test eax,eax
聽聽聽聽聽je foo+23h
聽聽聽聽聽jmp foo+18h
緙栬瘧鍓?聽聽聽聽聽緙栬瘧鍚幝?
for (錛涳紱)錛?聽聽聽聽jmp foo+23h
銆銆涓鐩簡鐒訛紝for (錛涳紱)鎸囦護灝戯紝涓嶅崰鐢ㄥ瘎瀛樺櫒錛岃屼笖娌℃湁鍒ゆ柇璺寵漿錛屾瘮while (1)濂姐?
5.浣跨敤鏁扮粍鍨嬩唬鏇挎寚閽堝瀷
銆銆浣跨敤鎸囬拡浼氫嬌緙栬瘧鍣ㄥ緢闅句紭鍖栧畠銆傚洜涓虹己涔忔湁鏁堢殑鎸囬拡浠g爜浼樺寲鐨勬柟娉曪紝緙栬瘧鍣ㄦ繪槸鍋囪鎸囬拡鍙互璁塊棶鍐呭瓨鐨勪換鎰忓湴鏂癸紝鍖呮嫭鍒嗛厤緇欏叾浠栧彉閲忕殑鍌ㄥ瓨絀洪棿銆傛墍浠ヤ負浜嗙紪璇戝櫒浜х敓浼樺寲寰楁洿濂界殑浠g爜錛岃閬垮厤鍦ㄤ笉蹇呰鐨勫湴鏂逛嬌鐢ㄦ寚閽堛備竴涓吀鍨嬬殑渚嬪瓙鏄闂瓨鏀懼湪鏁扮粍涓殑鏁版嵁銆侰++ 鍏佽浣跨敤鎿嶄綔絎?[] 鎴栨寚閽堟潵璁塊棶鏁扮粍錛屼嬌鐢ㄦ暟緇勫瀷浠g爜浼氳浼樺寲鍣ㄥ噺灝戜駭鐢熶笉瀹夊叏浠g爜鐨勫彲鑳芥с傛瘮濡傦紝x[0] 鍜寈[2] 涓嶅彲鑳芥槸鍚屼竴涓唴瀛樺湴鍧錛屼絾 *p 鍜?*q 鍙兘銆傚己鐑堝緩璁嬌鐢ㄦ暟緇勫瀷錛屽洜涓鴻繖鏍峰彲鑳戒細鏈夋剰鏂欎箣澶栫殑鎬ц兘鎻愬崌銆?
聽聽聽 涓嶅ソ鐨勪唬鐮?br />typedef struct
{
銆銆float x,y,z,w錛?br />} VERTEX錛?br />typedef struct
銆銆float m[4][4]錛?br />} MATRIX錛?br />void XForm(float* res, const float* v, const float* m, int nNumVerts)
{
銆銆float dp錛?br />銆銆int i錛?br />銆銆銆const VERTEX* vv = (VERTEX *)v錛?br />銆銆銆for (i = 0錛?i <錛?nNumVerts錛?i++)
銆銆{
銆銆銆銆dp = vv->錛泋 * *m ++錛?br />銆銆銆銆dp += vv->錛泍 * *m ++錛?br />銆銆銆銆dp += vv->錛泎 * *m ++錛?br />銆銆銆銆dp += vv->錛泈 * *m ++錛?br />銆銆銆銆*res ++ = dp錛涖銆銆銆銆銆// 鍐欏叆杞崲浜嗙殑 x
銆銆銆銆dp = vv->錛泋 * *m ++錛?br />銆銆銆銆dp += vv->錛泍 * *m ++錛?br />銆銆銆銆dp += vv->錛泎 * *m ++錛?br />銆銆銆銆dp += vv->錛泈 * *m ++錛?br />銆銆銆銆*res ++ = dp錛涖銆銆銆銆// 鍐欏叆杞崲浜嗙殑 y
銆銆銆銆dp = vv->錛泋 * *m ++錛?br />銆銆銆銆dp += vv->錛泍 * *m ++錛?br />銆銆銆銆dp += vv->錛泎 * *m ++錛?br />銆銆銆銆dp += vv->錛泈 * *m ++錛?br />銆銆銆銆*res ++ = dp錛涖銆銆銆// 鍐欏叆杞崲浜嗙殑 z
銆銆銆銆dp = vv->錛泋 * *m ++錛?br />銆銆銆銆dp += vv->錛泍 * *m ++錛?br />銆銆銆銆dp += vv->錛泎 * *m ++錛?br />銆銆銆銆dp += vv->錛泈 * *m ++錛?br />銆銆銆銆*res ++ = dp錛涖銆銆銆// 鍐欏叆杞崲浜嗙殑 w
銆銆銆銆vv ++錛涖銆銆銆銆銆銆 // 涓嬩竴涓煝閲?br />銆銆銆銆m -= 16錛?br />銆銆}
}
聽聽聽 鎺ㄨ崘鐨勪唬鐮?
typedef struct
{
銆銆float x,y,z,w錛?br />} VERTEX錛?br />typedef struct
{
銆銆float m[4][4]錛?br />} MATRIX錛?br />void XForm (float* res, const float* v, const float* m, int nNumVerts)
{
銆銆int i錛?br />銆銆const VERTEX* vv = (VERTEX*)v錛?br />銆銆const MATRIX* mm = (MATRIX*)m錛?br />銆銆VERTEX* rr = (VERTEX*)res錛?br />銆銆for (i = 0錛?i <錛?nNumVerts錛?i++)
銆銆{
銆銆銆銆rr->錛泋 = vv->錛泋 * mm->錛沵[0][0] + vv->錛泍 * mm->錛沵[0][1]
銆銆銆銆銆銆銆銆+ vv->錛泎 * mm->錛沵[0][2] + vv->錛泈 * mm->錛沵[0][3]錛?br />銆銆銆銆rr->錛泍 = vv->錛泋 * mm->錛沵[1][0] + vv->錛泍 * mm->錛沵[1][1]
銆銆銆銆銆銆銆銆+ vv->錛泎 * mm->錛沵[1][2] + vv->錛泈 * mm->錛沵[1][3]錛?br />銆銆銆銆rr->錛泎 = vv->錛泋 * mm->錛沵[2][0] + vv->錛泍 * mm->錛沵[2][1]
銆銆銆銆銆銆銆銆+ vv->錛泎 * mm->錛沵[2][2] + vv->錛泈 * mm->錛沵[2][3]錛?br />銆銆銆銆rr->錛泈 = vv->錛泋 * mm->錛沵[3][0] + vv->錛泍 * mm->錛沵[3][1]
銆銆銆銆銆銆銆銆+ vv->錛泎 * mm->錛沵[3][2] + vv->錛泈 * mm->錛沵[3][3]錛?br />銆銆}
}
銆銆娉ㄦ剰: 婧愪唬鐮佺殑杞寲鏄笌緙栬瘧鍣ㄧ殑浠g爜鍙戠敓鍣ㄧ浉緇撳悎鐨勩備粠婧愪唬鐮佸眰嬈″緢闅炬帶鍒朵駭鐢熺殑鏈哄櫒鐮併備緷闈犵紪璇戝櫒鍜岀壒孌婄殑婧愪唬鐮侊紝鏈夊彲鑳芥寚閽堝瀷浠g爜緙栬瘧鎴愮殑鏈哄櫒鐮佹瘮鍚岀瓑鏉′歡涓嬬殑鏁扮粍鍨嬩唬鐮佽繍琛岄熷害鏇村揩銆傛槑鏅虹殑鍋氭硶鏄湪婧愪唬鐮佽漿鍖栧悗媯鏌ユц兘鏄惁鐪熸鎻愰珮浜嗭紝鍐嶉夋嫨浣跨敤鎸囬拡鍨嬭繕鏄暟緇勫瀷銆?
6.鍏呭垎鍒嗚В灝忕殑寰幆
銆銆瑕佸厖鍒嗗埄鐢–PU鐨勬寚浠ょ紦瀛橈紝灝辮鍏呭垎鍒嗚В灝忕殑寰幆銆傜壒鍒槸褰撳驚鐜綋鏈韓寰堝皬鐨勬椂鍊欙紝鍒嗚В寰幆鍙互鎻愰珮鎬ц兘銆侭TW:寰堝緙栬瘧鍣ㄥ茍涓嶈兘鑷姩鍒嗚В寰幆銆?
涓嶅ソ鐨勪唬鐮?鎺ㄨ崘鐨勪唬鐮?
// 3D杞寲錛氭妸鐭㈤噺 V 鍜?4x4 鐭╅樀 M 鐩鎬箻
for (i = 0錛?i <錛?4錛?i ++)
{
銆銆r = 0錛?br />銆銆for (j = 0錛?j <錛?4錛?j ++)
銆銆{
銆銆銆銆r += M[j]*V[j]錛?br />銆銆}
}
r[0] = M[0][0]*V[0] + M[1][0]*V[1] + M[2][0]*V[2] + M[3][0]*V[3]錛?br />r[1] = M[0][1]*V[0] + M[1][1]*V[1] + M[2][1]*V[2] + M[3][1]*V[3]錛?br />r[2] = M[0][2]*V[0] + M[1][2]*V[1] + M[2][2]*V[2] + M[3][2]*V[3]錛?br />r[3] = M[0][3]*V[0] + M[1][3]*V[1] + M[2][3]*V[2] + M[3][3]*v[3]錛?
7.閬垮厤娌℃湁蹇呰鐨勮鍐欎緷璧?
銆銆褰撴暟鎹繚瀛樺埌鍐呭瓨鏃跺瓨鍦ㄨ鍐欎緷璧栵紝鍗蟲暟鎹繀欏誨湪姝g‘鍐欏叆鍚庢墠鑳藉啀嬈¤鍙栥傝櫧鐒禔MD Athlon絳塁PU鏈夊姞閫熻鍐欎緷璧栧歡榪熺殑紜歡錛屽厑璁稿湪瑕佷繚瀛樼殑鏁版嵁琚啓鍏ュ唴瀛樺墠璇誨彇鍑烘潵錛屼絾鏄紝濡傛灉閬垮厤浜嗚鍐欎緷璧栧茍鎶婃暟鎹繚瀛樺湪鍐呴儴瀵勫瓨鍣ㄤ腑錛岄熷害浼氭洿蹇傚湪涓孌靛緢闀跨殑鍙堜簰鐩鎬緷璧栫殑浠g爜閾句腑錛岄伩鍏嶈鍐欎緷璧栨樉寰楀挨鍏墮噸瑕併傚鏋滆鍐欎緷璧栧彂鐢熷湪鎿嶄綔鏁扮粍鏃訛紝璁稿緙栬瘧鍣ㄤ笉鑳借嚜鍔ㄤ紭鍖栦唬鐮佷互閬垮厤璇誨啓渚濊禆銆傛墍浠ユ帹鑽愮▼搴忓憳鎵嬪姩鍘繪秷闄よ鍐欎緷璧栵紝涓句緥鏉ヨ錛屽紩榪涗竴涓彲浠ヤ繚瀛樺湪瀵勫瓨鍣ㄤ腑鐨勪復鏃跺彉閲忋傝繖鏍峰彲浠ユ湁寰堝ぇ鐨勬ц兘鎻愬崌銆備笅闈竴孌典唬鐮佹槸涓涓緥瀛愶細
聽聽聽 涓嶅ソ鐨勪唬鐮?br />float x[VECLEN], y[VECLEN], z[VECLEN]錛?br />......
for (unsigned int k = 1錛?k <錛?VECLEN錛?k ++)
{
銆銆x[k] = x[k-1] + y[k]錛?br />}
for (k = 1錛?k <錛?VECLEN錛?k++)
{
銆銆x[k] = z[k] * (y[k] - x[k-1])錛?br />}
銆銆 鎺ㄨ崘鐨勪唬鐮?
float x[VECLEN], y[VECLEN], z[VECLEN]錛?br />......
float t(x[0])錛?br />for (unsigned int k = 1錛?k <錛?VECLEN錛?k ++)
{
銆銆t = t + y[k]錛?br />銆銆x[k] = t錛?br />}
t = x[0]錛?br />for (k = 1錛?k <錛?VECLEN錛?k ++)
{
銆銆t = z[k] * (y[k] - t)錛?br />銆銆x[k] = t錛?br />}
8.Switch 鐨勭敤娉?
銆銆Switch 鍙兘杞寲鎴愬縐嶄笉鍚岀畻娉曠殑浠g爜銆傚叾涓渶甯歌鐨勬槸璺寵漿琛ㄥ拰姣旇緝閾?鏍戙傛帹鑽愬case鐨勫間緷鐓у彂鐢熺殑鍙兘鎬ц繘琛屾帓搴忥紝鎶婃渶鏈夊彲鑳界殑鏀懼湪絎竴涓紝褰搒witch鐢ㄦ瘮杈冮摼鐨勬柟寮忚漿鍖栨椂錛岃繖鏍峰彲浠ユ彁楂樻ц兘銆傛澶栵紝鍦╟ase涓帹鑽愪嬌鐢ㄥ皬鐨勮繛緇殑鏁存暟錛屽洜涓哄湪榪欑鎯呭喌涓嬶紝鎵鏈夌殑緙栬瘧鍣ㄩ兘鍙互鎶妔witch 杞寲鎴愯煩杞〃銆?
聽聽聽 涓嶅ソ鐨勪唬鐮?br />int days_in_month, short_months, normal_months, long_months錛?br />......
switch (days_in_month)
{
銆銆case 28:
銆銆case 29:
銆銆銆銆short_months ++錛?br />銆銆銆銆break錛?br />銆銆case 30:
銆銆銆銆normal_months ++錛?br />銆銆銆銆break錛?br />銆銆case 31:
銆銆銆銆long_months ++錛?br />銆銆銆銆break錛?br />銆銆default:
銆銆銆銆cout <錛?lt;錛?"錛沵onth has fewer than 28 or more than 31 days"錛?<錛?lt;錛?endl錛?br />銆銆銆銆break錛?br />}
聽聽聽 鎺ㄨ崘鐨勪唬鐮?
int days_in_month, short_months, normal_months, long_months錛?br />......
switch (days_in_month)
{
銆銆case 31:
銆銆銆銆long_months ++錛?br />銆銆銆銆break錛?br />銆銆case 30:
銆銆銆銆normal_months ++錛?br />銆銆銆銆break錛?br />銆銆case 28:
銆銆case 29:
銆銆銆銆short_months ++錛?
銆銆銆銆break錛?br />銆銆default:
銆銆銆銆cout <錛?lt;錛?"錛沵onth has fewer than 28 or more than 31 days"錛?<錛?lt;錛?endl錛?br />銆銆銆銆break錛?br />}
9.鎵鏈夊嚱鏁伴兘搴旇鏈夊師鍨嬪畾涔?
銆銆涓鑸潵璇達紝鎵鏈夊嚱鏁伴兘搴旇鏈夊師鍨嬪畾涔夈傚師鍨嬪畾涔夊彲浠ヤ紶杈劇粰緙栬瘧鍣ㄦ洿澶氱殑鍙兘鐢ㄤ簬浼樺寲鐨勪俊鎭?
銆銆灝藉彲鑳戒嬌鐢ㄥ父閲?const)銆侰++ 鏍囧噯瑙勫畾錛屽鏋滀竴涓猚onst澹版槑鐨勫璞$殑鍦板潃涓嶈鑾峰彇錛屽厑璁哥紪璇戝櫒涓嶅瀹冨垎閰嶅偍瀛樼┖闂淬傝繖鏍峰彲浠ヤ嬌浠g爜鏇存湁鏁堢巼錛岃屼笖鍙互鐢熸垚鏇村ソ鐨勪唬鐮併?
10.鎻愬崌寰幆鐨勬ц兘
銆銆瑕佹彁鍗囧驚鐜殑鎬ц兘錛屽噺灝戝浣欑殑甯擱噺璁$畻闈炲父鏈夌敤錛堟瘮濡傦紝涓嶉殢寰幆鍙樺寲鐨勮綆楋級銆?
銆銆涓嶅ソ鐨勪唬鐮?鍦╢or()涓寘鍚笉鍙樼殑if()) 鎺ㄨ崘鐨勪唬鐮?
for( i ... )
{
銆銆if( CONSTANT0 )
銆銆{
銆銆銆銆DoWork0( i )錛?// 鍋囪榪欓噷涓嶆敼鍙楥ONSTANT0鐨勫?br />銆銆}
銆銆else
銆銆{
銆銆銆銆DoWork1( i )錛?// 鍋囪榪欓噷涓嶆敼鍙楥ONSTANT0鐨勫?br />銆銆}
}
if( CONSTANT0 )
{
銆銆for( i ... )
銆銆{
銆銆銆銆DoWork0( i )錛?br />銆銆}
}
else
{
銆銆for( i ... )
銆銆{
銆銆銆銆DoWork1( i )錛?br />銆銆}
}
銆銆濡傛灉宸茬粡鐭ラ亾if()鐨勫鹼紝榪欐牱鍙互閬垮厤閲嶅璁$畻銆傝櫧鐒朵笉濂界殑浠g爜涓殑鍒嗘敮鍙互綆鍗曞湴棰勬祴錛屼絾鏄敱浜庢帹鑽愮殑浠g爜鍦ㄨ繘鍏ュ驚鐜墠鍒嗘敮宸茬粡紜畾錛屽氨鍙互鍑忓皯瀵瑰垎鏀嫻嬬殑渚濊禆銆?銆銆鎶婃湰鍦板嚱鏁板0鏄庝負闈欐佺殑(static)
銆銆濡傛灉涓涓嚱鏁板湪瀹炵幇瀹冪殑鏂囦歡澶栨湭琚嬌鐢ㄧ殑璇濓紝鎶婂畠澹版槑涓洪潤鎬佺殑(static)浠ュ己鍒朵嬌鐢ㄥ唴閮ㄨ繛鎺ャ傚惁鍒欙紝榛樿鐨勬儏鍐典笅浼氭妸鍑芥暟瀹氫箟涓哄閮ㄨ繛鎺ャ傝繖鏍峰彲鑳戒細褰卞搷鏌愪簺緙栬瘧鍣ㄧ殑浼樺寲鈥斺旀瘮濡傦紝鑷姩鍐呰仈銆?
11.鑰冭檻鍔ㄦ佸唴瀛樺垎閰?
銆銆鍔ㄦ佸唴瀛樺垎閰嶏紙C++涓殑"錛沶ew"錛涳級鍙兘鎬繪槸涓洪暱鐨勫熀鏈被鍨嬶紙鍥涘瓧瀵歸綈錛夎繑鍥炰竴涓凡緇忓榻愮殑鎸囬拡銆備絾鏄鏋滀笉鑳戒繚璇佸榻愶紝浣跨敤浠ヤ笅浠g爜鏉ュ疄鐜板洓瀛楀榻愩傝繖孌典唬鐮佸亣璁炬寚閽堝彲浠ユ槧灝勫埌 long 鍨嬨?
銆銆渚嬪瓙
銆銆double* p = (double*)new BYTE[sizeof(double) * number_of_doubles+7L]錛?br />聽聽聽 double* np = (double*)((long(p) + 7L) &錛?鈥?L)錛?
銆銆鐜板湪錛屼綘鍙互浣跨敤 np 浠f浛 p 鏉ヨ闂暟鎹傛敞鎰忥細閲婃斁鍌ㄥ瓨絀洪棿鏃朵粛鐒跺簲璇ョ敤delete p銆?
12.浣跨敤鏄懼紡鐨勫茍琛屼唬鐮?
銆銆灝藉彲鑳芥妸闀跨殑鏈変緷璧栫殑浠g爜閾懼垎瑙f垚鍑犱釜鍙互鍦ㄦ祦姘寸嚎鎵ц鍗曞厓涓茍琛屾墽琛岀殑娌℃湁渚濊禆鐨勪唬鐮侀摼銆傚洜涓烘誕鐐規搷浣滄湁寰堥暱鐨勬綔浼忔湡錛屾墍浠ヤ笉綆″畠琚槧灝勬垚 x87 鎴?3DNow! 鎸囦護錛岃繖閮藉緢閲嶈銆傚緢澶氶珮綰ц璦錛屽寘鎷珻++錛屽茍涓嶅浜х敓鐨勬誕鐐硅〃杈懼紡閲嶆柊鎺掑簭錛屽洜涓洪偅鏄竴涓浉褰撳鏉傜殑榪囩▼銆傞渶瑕佹敞鎰忕殑鏄紝閲嶆帓搴忕殑浠g爜鍜屽師鏉ョ殑浠g爜鍦ㄤ唬鏁頒笂涓鑷村茍涓嶇瓑浠蜂簬璁$畻緇撴灉涓鑷達紝鍥犱負嫻偣鎿嶄綔緙轟箯綺劇‘搴︺傚湪涓浜涙儏鍐典笅錛岃繖浜涗紭鍖栧彲鑳藉鑷存剰鏂欎箣澶栫殑緇撴灉銆傚垢榪愮殑鏄紝鍦ㄥぇ閮ㄥ垎鎯呭喌涓嬶紝鏈鍚庣粨鏋滃彲鑳藉彧鏈夋渶涓嶉噸瑕佺殑浣嶏紙鍗蟲渶浣庝綅錛夋槸閿欒鐨勩?
銆銆涓嶅ソ鐨勪唬鐮?br />double a[100], sum錛?br />int i錛?br />sum = 0.0f錛?br />for (i=0錛?i<錛?00錛?i++)
銆銆sum += a錛?
聽聽聽 鎺ㄨ崘鐨勪唬鐮?
double a[100], sum1, sum2, sum3, sum4, sum錛?br />int i錛?br />sum1 = sum2 = sum3 = sum4 = 0.0錛?br />for (i = 0錛?i <錛?100錛?i += 4)
{
銆銆sum1 += a錛?br />銆銆sum2 += a[i+1]錛?br />銆銆sum3 += a[i+2]錛?br />銆銆sum4 += a[i+3]錛?br />}
sum = (sum4+sum3)+(sum1+sum2)錛?
銆銆瑕佹敞鎰忕殑鏄細浣跨敤4 璺垎瑙f槸鍥犱負榪欐牱浣跨敤浜?闃舵嫻佹按綰挎誕鐐瑰姞娉曪紝嫻偣鍔犳硶鐨勬瘡涓涓樁孌靛崰鐢ㄤ竴涓椂閽熷懆鏈燂紝淇濊瘉浜嗘渶澶х殑璧勬簮鍒╃敤鐜囥?
13.鎻愬嚭鍏叡瀛愯〃杈懼紡
銆銆鍦ㄦ煇浜涙儏鍐典笅錛孋++緙栬瘧鍣ㄤ笉鑳戒粠嫻偣琛ㄨ揪寮忎腑鎻愬嚭鍏叡鐨勫瓙琛ㄨ揪寮忥紝鍥犱負榪欐剰鍛崇潃鐩稿綋浜庡琛ㄨ揪寮忛噸鏂版帓搴忋傞渶瑕佺壒鍒寚鍑虹殑鏄紝緙栬瘧鍣ㄥ湪鎻愬彇鍏叡瀛愯〃杈懼紡鍓嶄笉鑳芥寜鐓т唬鏁扮殑絳変環鍏崇郴閲嶆柊瀹夋帓琛ㄨ揪寮忋傝繖鏃訛紝紼嬪簭鍛樿鎵嬪姩鍦版彁鍑哄叕鍏辯殑瀛愯〃杈懼紡錛堝湪VC.net閲屾湁涓欏光滃叏灞浼樺寲鈥濋夐」鍙互瀹屾垚姝ゅ伐浣滐紝浣嗘晥鏋滃氨涓嶅緱鑰岀煡浜嗭級銆?
鎺ㄨ崘鐨勪唬鐮?
float a, b, c, d, e, f錛?br />...
e = b * c / d錛?br />f = b / d * a錛?br />float a, b, c, d, e, f錛?br />...
const float t(b / d)錛?br />e = c * t錛?br />f = a * t錛?
鎺ㄨ崘鐨勪唬鐮?
float a, b, c, e, f錛?br />...
e = a / c錛?br />f = b / c錛?br />float a, b, c, e, f錛?br />...
const float t(1.0f / c)錛?br />e = a * t錛?br />f = b * t錛?
14.緇撴瀯浣撴垚鍛樼殑甯冨眬
銆銆寰堝緙栬瘧鍣ㄦ湁鈥滀嬌緇撴瀯浣撳瓧錛屽弻瀛楁垨鍥涘瓧瀵歸綈鈥濈殑閫夐」銆備絾鏄紝榪樻槸闇瑕佹敼鍠勭粨鏋勪綋鎴愬憳鐨勫榻愶紝鏈変簺緙栬瘧鍣ㄥ彲鑳藉垎閰嶇粰緇撴瀯浣撴垚鍛樼┖闂寸殑欏哄簭涓庝粬浠0鏄庣殑涓嶅悓銆備絾鏄紝鏈変簺緙栬瘧鍣ㄥ茍涓嶆彁渚涜繖浜涘姛鑳斤紝鎴栬呮晥鏋滀笉濂姐傛墍浠ワ紝瑕佸湪浠樺嚭鏈灝戜唬浠風殑鎯呭喌涓嬪疄鐜版渶濂界殑緇撴瀯浣撳拰緇撴瀯浣撴垚鍛樺榻愶紝寤鴻閲囧彇榪欎簺鏂規硶錛?
銆銆A鎸夌被鍨嬮暱搴︽帓搴?
銆銆鎶婄粨鏋勪綋鐨勬垚鍛樻寜鐓у畠浠殑綾誨瀷闀垮害鎺掑簭錛屽0鏄庢垚鍛樻椂鎶婇暱鐨勭被鍨嬫斁鍦ㄧ煭鐨勫墠闈€?
銆銆鎶婄粨鏋勪綋濉厖鎴愭渶闀跨被鍨嬮暱搴︾殑鏁村嶆暟
銆銆鎶婄粨鏋勪綋濉厖鎴愭渶闀跨被鍨嬮暱搴︾殑鏁村嶆暟銆傜収榪欐牱錛屽鏋滅粨鏋勪綋鐨勭涓涓垚鍛樺榻愪簡錛屾墍鏈夋暣涓粨鏋勪綋鑷劧涔熷氨瀵歸綈浜嗐備笅闈㈢殑渚嬪瓙婕旂ず浜嗗浣曞緇撴瀯浣撴垚鍛樿繘琛岄噸鏂版帓搴忥細
銆銆涓嶅ソ鐨勪唬鐮侊紝鏅氶『搴?鎺ㄨ崘鐨勪唬鐮侊紝鏂扮殑欏哄簭騫舵墜鍔ㄥ~鍏呬簡鍑犱釜瀛楄妭
struct
{
銆銆char a[5]錛?br />銆銆long k錛?br />銆銆double x錛?br />} baz錛?br />struct
{
銆銆double x錛?br />銆銆long k錛?br />銆銆char a[5]錛?br />char pad[7]錛?br />} baz錛?
銆銆B鎸夋暟鎹被鍨嬬殑闀垮害鎺掑簭鏈湴鍙橀噺
銆銆褰撶紪璇戝櫒鍒嗛厤緇欐湰鍦板彉閲忕┖闂存椂錛屽畠浠殑欏哄簭鍜屽畠浠湪婧愪唬鐮佷腑澹版槑鐨勯『搴忎竴鏍鳳紝鍜屼笂涓鏉¤鍒欎竴鏍鳳紝搴旇鎶婇暱鐨勫彉閲忔斁鍦ㄧ煭鐨勫彉閲忓墠闈€傚鏋滅涓涓彉閲忓榻愪簡錛屽叾瀹冨彉閲忓氨浼氳繛緇殑瀛樻斁錛岃屼笖涓嶇敤濉厖瀛楄妭鑷劧灝變細瀵歸綈銆傛湁浜涚紪璇戝櫒鍦ㄥ垎閰嶅彉閲忔椂涓嶄細鑷姩鏀瑰彉鍙橀噺欏哄簭錛屾湁浜涚紪璇戝櫒涓嶈兘浜х敓4瀛楄妭瀵歸綈鐨勬爤錛屾墍浠?瀛楄妭鍙兘涓嶅榻愩備笅闈㈣繖涓緥瀛愭紨紺轟簡鏈湴鍙橀噺澹版槑鐨勯噸鏂版帓搴忥細
銆銆涓嶅ソ鐨勪唬鐮侊紝鏅氶『搴?鎺ㄨ崘鐨勪唬鐮侊紝鏀硅繘鐨勯『搴?
short ga, gu, gi錛?br />long foo, bar錛?br />double x, y, z[3]錛?br />char a, b錛?br />float baz錛?br />double z[3]錛?br />double x, y錛?br />long foo, bar錛?br />float baz錛?br />short ga, gu, gi錛?
14.閬垮厤涓嶅繀瑕佺殑鏁存暟闄ゆ硶
銆銆鏁存暟闄ゆ硶鏄暣鏁拌繍綆椾腑鏈鎱㈢殑錛屾墍浠ュ簲璇ュ敖鍙兘閬垮厤銆備竴縐嶅彲鑳藉噺灝戞暣鏁伴櫎娉曠殑鍦版柟鏄繛闄わ紝榪欓噷闄ゆ硶鍙互鐢變箻娉曚唬鏇褲傝繖涓浛鎹㈢殑鍓綔鐢ㄦ槸鏈夊彲鑳藉湪綆椾箻縐椂浼氭孩鍑猴紝鎵浠ュ彧鑳藉湪涓瀹氳寖鍥寸殑闄ゆ硶涓嬌鐢ㄣ?
銆銆涓嶅ソ鐨勪唬鐮?鎺ㄨ崘鐨勪唬鐮?
int i, j, k, m錛?br />m = i / j / k錛?br />int i, j, k, m錛?br />m = i / (j * k)錛?
15.鎶婇綣佷嬌鐢ㄧ殑鎸囬拡鍨嬪弬鏁版嫹璐濆埌鏈湴鍙橀噺
銆銆閬垮厤鍦ㄥ嚱鏁頒腑棰戠箒浣跨敤鎸囬拡鍨嬪弬鏁版寚鍚戠殑鍊箋傚洜涓虹紪璇戝櫒涓嶇煡閬撴寚閽堜箣闂存槸鍚﹀瓨鍦ㄥ啿紿侊紝鎵浠ユ寚閽堝瀷鍙傛暟寰寰涓嶈兘琚紪璇戝櫒浼樺寲銆傝繖鏍鋒槸鏁版嵁涓嶈兘琚瓨鏀懼湪瀵勫瓨鍣ㄤ腑錛岃屼笖鏄庢樉鍦板崰鐢ㄤ簡鍐呭瓨甯﹀銆傛敞鎰忥紝寰堝緙栬瘧鍣ㄦ湁鈥滃亣璁句笉鍐茬獊鈥濅紭鍖栧紑鍏籌紙鍦╒C閲屽繀欏繪墜鍔ㄦ坊鍔犵紪璇戝櫒鍛戒護琛?Oa鎴?Ow錛夛紝榪欏厑璁哥紪璇戝櫒鍋囪涓や釜涓嶅悓鐨勬寚閽堟繪槸鏈変笉鍚岀殑鍐呭錛岃繖鏍峰氨涓嶇敤鎶婃寚閽堝瀷鍙傛暟淇濆瓨鍒版湰鍦板彉閲忋傚惁鍒欙紝璇峰湪鍑芥暟涓寮濮嬫妸鎸囬拡鎸囧悜鐨勬暟鎹繚瀛樺埌鏈湴鍙橀噺銆傚鏋滈渶瑕佺殑璇濓紝鍦ㄥ嚱鏁扮粨鏉熷墠鎷瘋礉鍥炲幓銆?銆銆
聽聽聽 涓嶅ソ鐨勪唬鐮?
// 鍋囪 q != r
void isqrt(unsigned long a, unsigned long* q, unsigned long* r)
{
銆銆*q = a錛?br />銆銆if (a >錛?0)
銆銆{
銆銆銆銆while (*q >錛?(*r = a / *q))
銆銆銆銆{
銆銆銆銆銆銆*q = (*q + *r) >錛?gt;錛?1錛?br />銆銆銆銆}
銆銆}
銆銆*r = a - *q * *q錛?br />}
聽聽聽 鎺ㄨ崘鐨勪唬鐮?br />// 鍋囪 q != r
void isqrt(unsigned long a, unsigned long* q, unsigned long* r)
{
銆銆unsigned long qq, rr錛?br />銆銆qq = a錛?br />銆銆if (a >錛?0)
銆銆{
銆銆銆銆while (qq >錛?(rr = a / qq))
銆銆銆銆{
銆銆銆銆銆銆qq = (qq + rr) >錛?gt;錛?1錛?br />銆銆銆銆}
銆銆}
銆銆rr = a - qq * qq錛?br />銆銆*q = qq錛?br />銆銆*r = rr錛?br />}
16.璧嬪間笌鍒濆鍖?br />鍏堢湅鐪嬩互涓嬩唬鐮侊細
class CInt
{
銆銆int m_i錛?
public:
銆銆CInt(int a = 0):m_i(a) { cout <錛?lt;錛?"錛汣Int"錛?<錛?lt;錛?endl錛?}
銆銆~CInt() { cout <錛?lt;錛?"錛泘CInt"錛?<錛?lt;錛?endl錛?}
銆銆CInt operator + (const CInt&錛?a) { return CInt(m_i + a.GetInt())錛?}
銆銆void SetInt(const int i)銆銆{ m_i = i錛?}
銆銆int GetInt() const銆銆銆銆銆銆{ return m_i錛?}
}錛?br />聽聽聽 涓嶅ソ鐨勪唬鐮?
void main()
{
銆銆CInt a, b, c錛?br />銆銆a.SetInt(1)錛?br />銆銆b.SetInt(2)錛?br />銆銆c = a + b錛?br />}
聽聽聽 鎺ㄨ崘鐨勪唬鐮?br />void main()
{
銆銆CInt a(1), b(2)錛?br />銆銆CInt c(a + b)錛?br />}
銆銆榪欎袱孌典唬鐮佹墍浣滅殑浜嬮兘涓鏍鳳紝浣嗛偅涓涓洿濂藉憿錛熺湅鐪嬭緭鍑虹粨鏋滃氨浼氬彂鐜幫紝涓嶅ソ鐨勪唬鐮佽緭鍑轟簡鍥涗釜"錛汣Int"錛涘拰鍥涗釜"錛泘CInt"錛涳紝鑰屾帹鑽愮殑浠g爜鍙緭鍑轟笁涓備篃灝辨槸璇達紝絎簩涓緥瀛愭瘮絎竴涓緥瀛愬皯鐢熸垚涓嬈′復鏃跺璞°俉hy? 璇鋒敞鎰忥紝絎竴涓腑鐨刢鐢ㄧ殑鏄厛澹版槑鍐嶈祴鍊肩殑鏂規硶錛岀浜屼釜鐢ㄧ殑鏄垵濮嬪寲鐨勬柟娉曪紝瀹冧滑鏈夋湰璐ㄧ殑鍖哄埆銆傜涓涓緥瀛愮殑"錛沜 = a + b"錛涘厛鐢熸垚涓涓復鏃跺璞$敤鏉ヤ繚瀛榓 + b鐨勫鹼紝鍐嶆妸璇ヤ復鏃跺璞$敤浣嶆嫹璐濈殑鏂規硶緇檆璧嬪鹼紝鐒跺悗涓存椂瀵硅薄琚攢姣併傝繖涓復鏃跺璞″氨鏄偅涓鍑烘潵鐨勫璞°傜浜屼釜渚嬪瓙鐩存帴鐢ㄦ嫹璐濇瀯閫犲嚱鏁扮殑鏂規硶瀵筩鍒濆鍖栵紝涓嶄駭鐢熶復鏃跺璞°傛墍浠ワ紝灝介噺鍦ㄩ渶瑕佷嬌鐢ㄤ竴涓璞℃椂鎵嶅0鏄庯紝騫剁敤鍒濆鍖栫殑鏂規硶璧嬪垵鍊箋?
17.灝介噺浣跨敤鎴愬憳鍒濆鍖栧垪琛?
銆銆鍦ㄥ垵濮嬪寲綾葷殑鎴愬憳鏃訛紝灝介噺浣跨敤鎴愬憳鍒濆鍖栧垪琛ㄨ屼笉鏄紶緇熺殑璧嬪兼柟寮忋?
銆銆涓嶅ソ鐨勪唬鐮?
class CMyClass
{
銆銆string strName錛?
public:
銆銆CMyClass(const string&錛?str)錛?br />}錛?
CMyClass::CMyClass(const string&錛?str)
{
銆銆strName = str錛?br />}
聽聽聽 鎺ㄨ崘鐨勪唬鐮?br />class CMyClass
{
銆銆string strName錛?br />銆銆int i錛?br />public:
銆銆CMyClass(const string&錛?str)錛?br />}錛?
CMyClass::CMyClass(const string&錛泂tr)
聽聽 :strName(str)
{
銆銆涓嶅ソ鐨勪緥瀛愮敤鐨勬槸璧嬪肩殑鏂瑰紡銆傝繖鏍鳳紝strName浼氬厛琚緩绔嬶紙璋冪敤浜唖tring鐨勯粯璁ゆ瀯閫犲嚱鏁幫級錛屽啀鐢卞弬鏁皊tr璧嬪箋傝屾帹鑽愮殑渚嬪瓙鐢ㄧ殑鏄垚鍛樺垵濮嬪寲鍒楄〃錛宻trName鐩存帴鏋勯犱負str錛屽皯璋冪敤涓嬈¢粯璁ゆ瀯閫犲嚱鏁幫紝榪樺皯浜嗕竴浜涘畨鍏ㄩ殣鎮c?/p>
]]>
銆銆鏃犳暟嬈″惉鍒扳滄垜瑕佸紑濮嬪涔燙++!鈥濈殑鍛愬枈錛屾棤鏁版鍚埌鈥淐++澶鏉備簡錛屾垜鐪熺殑瀛︿笉浼氣濈殑鏃犲銆係tan Lippman鍏堢敓鏇懼湪銆奀++ Primer銆嬩竴涔︿腑鎸囧嚭鈥淐++鏄渶涓洪毦瀛︾殑楂樼駭紼嬪簭璁捐璇█涔嬩竴鈥濓紝浜轟滑甯稿皢鈥滀箣涓鈥濆幓鎺変互琛ㄨ揪鑷繁瀵笴++鐨勬暚鐣忋傝瘹鐒訛紝C++紼嬪簭璁捐璇█瀵逛簬瀛︿範鑰呯殑紜湁寰堝闅句互閫捐秺鐨勯縛娌燂紝浣撶郴緇撴瀯鐨勫簽澶э紝搴旀帴涓嶆殗騫朵笉鏂墿鍏呯殑鐗規р︹﹂櫎姝や箣澶栵紝鍙傝冭祫鏂欎箣澶氫笌鍐楁潅浣垮畠鐨勫涔犺呮湜鑰屽嵈姝ワ紝嬈叉眰娣卞叆鑰呰嫤涓嶅牚璦銆傚笇鏈涜繖涓浠戒笉瀹屽叏瀵煎紩鑳藉鎴愪負鎮–++瀛︿範涔嬭礬涓婄殑寮曡礬鐏?/p>
銆銆鎾板啓鏈枃鐨勫垵琛峰茍涓嶆墦綆楀甫棰嗗ぇ瀹朵綋楠屽彜鑰佺殑C++鍘嗗彶錛屽鏋滀綘鎯充簡瑙++鐨勫巻鍙蹭笌鍏跺墠鏈熷彂灞曚腑璇稿鎶鏈殑婕斿彉錛屼綘搴斿綋鍘誨弬鑰傿jarne鐨勩奣he Design and Evolution of C++銆嬨傚綋鐒朵篃涓嶆墦綆楃粰澶у涓涓棤鎵涓嶅寘鐨勫疂鍏革紙騫墮潪涓嶆兂錛氬叾涓鏄洜姘村鉤鏈夐檺錛屽叾浜屾棤濂圕++涔嬪崥澶х簿娣憋級錛屾墍緇欏嚭鐨勪粎浠呮槸涓浜涙垜浠涓哄浜庢兂瀛︿範C++鐨勫箍澶ц鑰呮潵璇存渶閲嶈騫朵笖瑙︽墜鍙強鐨勫紑鍙戜笌瀛︿範璧勬簮銆?/p>
銆銆鏈枃浠嬬粛騫跺垎鏋愪簡涓浜涚紪璇戝櫒錛屽紑鍙戠幆澧冿紝搴擄紝灝戦噺鐨勪功綾嶄互鍙婂弬鑰冪綉绔欙紝騫朵笖灝藉彲鑳藉皾璇曠潃緇欏嚭涓涓埄鐢ㄨ繖浜涜祫婧愮殑瀵煎紩錛屾湜瀵瑰鍚屾垜浠竴鏍風殑鍒濆鑰呰兘澶熸湁鎵瑁ㄧ泭銆?/p>
聽聽聽 銆2錛岀紪璇戝櫒
銆銆鍦–++涔嬪鐨勪換浣曡璦涓紝緙栬瘧鍣ㄩ兘浠庢潵娌℃湁鍙楀埌榪囧姝や箣閲嶈銆傚洜涓篊++鏄竴闂ㄧ浉褰撳鏉傜殑璇█錛屾墍浠ョ紪璇戝櫒涔熼毦浜庢瀯寤恒傜洿鍒版渶榪戞垜浠墠寮濮嬭兘澶熶嬌鐢ㄤ笂瀹屽叏絎﹀悎C++鏍囧噯鐨勭紪璇戝櫒錛堝摝錛屼綘鍙兘浼氳矗鎬偅浜涚紪璇戝櫒鍘傚晢涓嶈兘灝芥棭鐨勬彁渚涚鍚堟爣鍑嗙殑緙栬瘧鍣紝榪欏彧鑳芥粬浠悇鑷淮緋葷潃鑷韓鐨勪竴濂楀埆浜轟笉鎰挎帴鍙楃殑鏍囧噯錛夈備粈涔堬紵浣犺榪欐棤鍏崇揣瑕侊紵鍝︼紝涓嶏紝浣犳墍闇瑕佺殑鏄拰鏍囧噯鍖朇++楂樺害鍏煎鐨勭紪璇戠幆澧冦傞暱榪滄潵鐪?br />錛屽彧鏈夎繖鏍風殑緙栬瘧鍣ㄥC++寮鍙戜漢鍛樻潵璇存墠鏄渶鏈夋剰涔夌殑宸ュ叿錛屽挨鍏舵槸瀵逛簬紼嬪簭璁捐璇█鐨勫涔犺呫備竴鑷蟲ц浠g爜鍏峰鍙Щ妞嶆э紝騫惰涓闂ㄨ璦鍙婂叾搴撶殑搴旂敤鏇翠負騫挎硾銆傚棷錛屾槸鐨勶紝鎴戜滑榪欓噷鍙墦綆椾粙緇嶄竴浜涘叕璁ょ殑浼樼緙栬瘧鍣ㄣ?/p>
銆銆2.1 Borland C++
銆銆榪欎釜鏄疊orland C++ Builder鍜孊orland C++ Builder X榪欎袱縐嶅紑鍙戠幆澧冪殑鍚庡彴緙栬瘧鍣ㄣ傦紙鍝︼紝鎴戜箣鎵浠ュ皢涔嬪垎涓轟袱縐嶅紑鍙戠幆澧冧綘搴斿綋鑳芥槑鐧戒負浠涔堬紝姝eDelphi7鍒癉elphi8鐨勮漿鍙橈紝鏄潻鍛芥х殑涓や唬銆傦級Borland C++鐢辮佺墝寮鍙戝伐鍏峰巶鍟咮orland鍊懼姏鎵撻犮傝鍏徃鐨勭紪璇戝櫒绱犱互閫熷害蹇紝絀洪棿鏁堢巼楂樿憲縐幫紝Borland C++ 緋誨垪緙栬瘧鍣ㄧ鎵夸簡榪欎釜浼犵粺錛屽睘浜庨潪甯鎬紭璐ㄧ殑緙栬瘧鍣ㄣ傛爣鍑嗗寲鏂歸潰鏃╁湪5.5鐗堟湰鐨勭紪璇戝櫒涓鏍囧噯鍖朇++鐨勫吋瀹瑰氨杈懼埌浜?2.73%銆傜洰鍓嶆渶鏂扮増鏈槸Borland C++ Builder X涓殑6.0鐗堟湰錛屽畼鏂圭О100%絎﹀悎ANSI/ISO鐨凜++鏍囧噯浠ュ強C99鏍囧噯銆傚棷鈥﹁繖姝f槸鎴戝墠闈㈡墍鎸囩殑鈥滃畬鍏ㄧ鍚圕++鏍囧噯鐨勭紪璇戝櫒鈥濄?/p>
銆銆2.2 Visual C++
銆銆榪欎釜姝f槸鎴戜滑鐔熺煡鐨刅isual Studio 鍜?Visual Studio.net 2002, 2003浠ュ強2005 Whidbey涓甫鐨凜++緙栬瘧鍣ㄣ傜敱Microsoft鍏徃鐮斿埗銆傚湪Visual Studio 6.0涓紝鍥犱負緙栬瘧鍣ㄦ湁澶鍦版柟涓嶈兘涓庡悗鏉ュ嚭鐜扮殑C++鏍囧噯鐩稿惢鍚堣岄ケ鍙楁壒璇勶紙鎯蟲兂浣犲湪浣跨敤STL鐨勬椂鍊欑紪璇戞椂鎶ュ嚭鐨勯偅浜涗護浜哄帉鎭剁殑error鍜寃arning鍚э級銆俈C++6.0瀵規爣鍑嗗寲C+
+鐨勫吋瀹瑰彧鏈?3.43%銆備絾鏄殢鐫C++緙栬瘧鍣ㄨ璁″ぇ甯圫tanley Lippman浠ュ強璇稿C++紺劇兢杈句漢鐨勫姞鐩燂紝鍦╒isual Studio.NET 2003涓紝Visual C++緙栬瘧鍣ㄥ凡緇忔垚涓轟竴涓潪甯告垚鐔熷彲*鐨凜++緙栬瘧鍣ㄤ簡銆侱r.Dobb's Journal鐨勮瘎嫻嬫樉紺篤isual C++7.1瀵規爣鍑咰++鐨勫吋瀹規ч珮杈?8.22%錛屼竴搴︽垚涓篊BX涔嬪墠鍏煎鎬ф渶濂界殑緙栬瘧鍣ㄣ傜粨鍚堝己澶х殑Visual Studio.NET寮鍙戠幆澧冿紝鏄竴涓潪甯鎬笉閿欑殑閫夋嫨銆傝嚦浜嶹hidbey鏃朵唬鐨刅isual C++,浼間箮寰蔣鎵鏈鍏蟲敞鐨勬槸C++/CLI鈥︹︽垜浠笉鎯寵瘎璁哄井杞笅涓浠g殑C++緙栬瘧鍣ㄥ鏍囧噯鍖栧吋瀹瑰浣曪紝浣嗕粬紜疄瓚婃潵瓚婇傚悎.NET (鍏跺疄浣犲拰鎴戠殑鎰熻鍙兘鏄竴鏍風殑錛屽井杞笉搴斿綋鎶婃爣鍑咰++榪欏潡鑲ヨ倝涓㈢粰Borland,鐒惰屽井杞彲鑳藉茍涓嶈繖鏍瘋涓?銆?/p>
銆銆2.3 GNU C++
銆銆钁楀悕鐨勫紑婧怌++緙栬瘧鍣ㄣ傛槸綾籙nix鎿嶄綔緋葷粺涓嬬紪鍐機++紼嬪簭鐨勯閫夈傜壒鐐規槸鏈夐潪甯稿ソ鐨勭Щ妞嶆э紝浣犲彲浠ュ湪闈炲父騫挎硾鐨勫鉤鍙頒笂浣跨敤瀹冿紝鍚屾椂涔熸槸緙栧啓璺ㄥ鉤鍙幫紝宓屽叆寮忕▼搴忓緢濂界殑閫夋嫨銆傚彟澶栧湪絎﹀悎鏍囧噯榪欎釜鏂歸潰涓鐩撮兘闈炲父濂斤紝GCC3.3澶ф鑳藉杈懼埌96.15%銆備絾鏄敱浜庡叾璺ㄥ鉤鍙扮殑鐗規э紝鍦ㄤ唬鐮佸昂瀵擱熷害絳変紭鍖栦笂鐣ュ井宸竴鐐廣?/p>
銆銆鍩轟簬GNU C++鐨勭紪璇戝櫒鏈夊緢澶氾紝姣斿錛?/p>
銆銆(1) Mingw
銆銆GCC鐨勪竴涓猈indows鐨勭Щ妞嶇増鏈紙Dev-C++鐨勫悗鍙幫級
銆銆(2) Cygwin
銆銆http://sources.redhat.com/cygwin/
銆銆GCC鐨勫彟澶栦竴涓猈indows縐繪鐗堟湰鏄疌ygwin鐨勪竴閮ㄥ垎錛孋ygwin鏄疻indows涓嬬殑涓涓猆nix浠跨湡鐜銆備弗鏍肩殑璇存槸妯℃嫙GNU鐨勭幆澧冿紝榪欎篃灝辨槸"Gnu's Not Unix"瑕佽〃杈劇殑鎰忔濓紝鍣紝鎵繙浜嗭紝榪欏茍涓嶆槸鎴戜滑鍦ㄨ繖閲屽叧蹇冪殑瀹炶川鍐呭銆?/p>
銆銆(3) Djgpp
銆銆http://www.delorie.com/djgpp/
銆銆榪欐槸GCC鐨凞OS縐繪鐗堟湰銆?/p>
銆銆(4) RSXNT
銆銆http://www.mathematik.uni-bielefeld.de/~rainer/
銆銆榪欐槸GCC鐨凞OS鍜學indows縐繪鐗堟湰銆?/p>
銆銆(5) Intel C++
銆銆钁楀悕CPU鍒墮犲巶鍟咺ntel鍑哄搧鐨勭紪璇戝櫒錛孲pecial Design for Intel x86錛佸浜嶪ntel x86緇撴瀯鐨凜PU緇忚繃鐗瑰埆鐨勪紭鍖栥傚湪鏈変簺搴旂敤鎯呭喌涓嬶紝鐗瑰埆鏄暟鍊艱綆楃瓑楂樻ц兘搴旂敤錛屼粎浠呴噰鐢↖ntel鐨勭紪璇戝櫒緙栬瘧灝辮兘澶у箙搴︾殑鎻愰珮鎬ц兘銆?/p>
銆銆(6) Digital Mars C++
銆銆緗戠粶涓婃彁渚涘厤璐逛笅杞斤紝Zortech/Symantec C++鐨勭戶鎵胯咃紝鍏跺墠韜湪褰撳勾鎯ㄧ儓鐨凜++鍥涘浗鎴樹腑涔熸槸涓昏涔嬩竴銆?/p>
銆銆3錛屽紑鍙戠幆澧?/p>
銆銆寮鍙戠幆澧冨浜庣▼搴忓憳鐨勪綔鐢ㄤ笉璦鑰屽柣銆傞夋嫨鑷繁鏈濆鐩稿鐨勭幆澧冧篃涓嶆槸瀹規槗鐨勪簨鎯咃紝鐗瑰埆鏄湪IDE濡傛涓板瘜鐨勬儏鍐典笅銆備笅闈㈠氨鏄垜浠帹鑽愮殑涓浜涘父瑙佺殑C++寮鍙戠幆澧冿紝騫舵病鏈夊寘鎷竴浜涘皬鍨嬬殑錛岀綍瑙佺殑IDE銆傚叾涓換浣曚竴嬈鵑兘鏄姛鑳戒赴瀵岋紝鍙互鐢ㄤ綔鏃ュ父寮鍙戜嬌鐢ㄧ殑銆傚浜庝笉鍚屽眰闈㈢殑寮鍙戣咃紝璇峰弬瑙佸唴鏂囧叧浜庨傜敤瀵硅薄鐨勬弿榪般?/p>
銆銆3.1 Visual Studio 6.0
銆銆榪欎釜铏界劧鏄疢icrosoft鍏徃鐨勮佺増鏈殑寮鍙戠幆澧冿紝浣嗘槸閴翠簬鍏跺悗緇х増鏈琕isualStudio.NET鐨勫簽澶ц韓韜紝浠ュ強鍒濆鑰呭茍涓嶉偅涔堥珮鐨勫姛鑳借姹傦紝鎵浠ユ帹鑽愯繖涓紑鍙戠幆澧冪粰C++鐨勫垵瀛﹁咃紝渚涘叾瀛︿範C++鐨勬渶鍩烘湰鐨勯儴鍒嗭紝姣斿C鐨勯偅閮ㄥ垎瀛愰泦錛屽綋鐒朵綘鍒寚鏈涗粬鑳藉鏀寔鏈鏂扮殑C99鏍囧噯銆傚湪鏃ュ父鐨勫紑鍙戜腑錛屼粛鐒舵湁寰堝鍏徃浣跨敤榪欎釜緇忓吀紼沖畾鐨勭幆澧冿紝姣斿絎旇呭氨鐪嬫浘浜茶鏈変簺鍏徃灝嗗叾緙栬瘧鍣ㄦ浛鎹負GCC鍋氭墜鏈哄紑鍙戜箣鐢ㄣ?/p>
銆銆3.2 Visual Studio.NET 2003
銆銆浣滀負Microsoft鍏徃瀹樻柟姝e紡鍙戝竷鐨勬渶鏂扮増鏈紑鍙戠幆澧冿紝鍏朵腑鏈夊お澶氭縺鍔ㄤ漢蹇冪殑鍔熻兘銆傜粨鍚堝叾鏈鏂扮殑C++緙栬瘧鍣ㄣ傚浜庢満鍣ㄩ厤緗瘮杈冨ソ鐨勫紑鍙戜漢鍛樻潵璇達紝浣跨敤榪欎釜寮鍙戠幆澧冨皢鑳芥弧瓚沖叾澶ч儴鍒嗙殑瑕佹眰銆傝繖閲屼笉鎵撶畻鍗曠嫭璇碫isual Studio Whidbey,铏界劧Visual Studio .NET 2005 - Whidbey紺懼尯棰勮鐗堝凡緇忔帹鍑猴紝浣嗘殏涓嶆槸寰堢ǔ瀹氾紝璇昏呭彲浠ヤ翰韜幓浣撻獙銆?/p>
銆銆3.3 Borland C++ Builder 6
銆銆榪欎釜騫朵笉鏄疊orland鐨凜++寮鍙戠幆澧冪殑鏈鏂扮増鏈傞夋嫨瀹冪殑鍘熷洜鏄畠涓嶆槸鐢↗ava鍐欑殑IDE錛岄熷害姣旇緝蹇傚畠鏈変竴涓緢瀹屽杽鐨凣UI紿椾綋璁捐鍣紝鍜孌elphi鍏辯敤涓涓猇CL銆傜敱浜庤繖浜涚壒鐐癸紝姣旇緝閫傚悎鍒濆鑰呬笂鎵嬨備絾鏄敱浜庡叾GUI鐨勪腑蹇冧綅緗紝鍙兘涓嶅埄浜庡浜嶤++璇█鐨勫涔犮傝屼笖鍏朵負浜嗘敮鎸乂CL榪欎釜Object Pascal鍐欑殑搴撲篃瀵笴++榪涜浜嗕竴浜涚鏈夌殑鎵╁厖銆備嬌寰椾漢浠湁涓涓笉寰椾笉鎺ュ彈鐨勪簨瀹烇細鈥淏orland C++ Builder 6鐨勯珮鎵?br />鍑犱箮閮芥槸Delphi楂樻墜鈥濄?/p>
銆銆3.4 Borland C++ Builder X
銆銆姝e鍓嶆枃鎵榪幫紝铏界劧鐗堟湰鍙蜂笂鍜屽墠闈㈤偅涓狪DE闈炲父鐩歌薄錛屼絾鏄叾瀹炲畠浠槸瀹屽叏涓嶅悓鐨勪袱涓泦鎴愬紑鍙戠幆澧冦侰++Builder鏇村鐨勬槸涓涓拰Delphi鍚屾鐨凜++鐗堟湰鐨勫紑鍙戠幆澧冿紝C++BuilderX鍒欐槸瀹屽叏浠嶤++鐨勮搴︽濊冨緱鍑虹殑涓涓姛鑳戒赴瀵岀殑IDE銆傚叾鏈澶х殑鐗圭偣鏄法騫沖彴錛岃法緙栬瘧鍣紝澶氱Framework鐨勯泦鎴愶紝騫朵笖鏈変竴涓猈xWindows涓哄熀紜鐨凣UI璁捐鍣ㄣ傚挨鍏舵槸閲囩敤浜嗙函C++鏉ラ噸鍐欎簡鏁翠釜Framework,鎽掑純浜嗕互鍓嶄護浜烘棤濂堢殑鐗堟湰銆傚浜嶤++鐨勫紑鍙戞潵璇達紝浠庣紪璇戝櫒錛屽埌搴擄紝鍒板姛鑳介泦鎴愰兘鏄潪甯哥悊鎯崇殑銆傚彲浠ラ瑙侊紝Borland C++ Builder X 2.0寰堝煎緱C++鐖卞ソ鑰呮湡寰呫傚敮涓浠や漢闅懼牚涔嬪鏄綔涓轟竴涓狢++鐨勫紑鍙戝伐鍏鳳紝鍏禝DE鏄敤Java鍐欑殑錛屽湪閰嶇疆涓嶅鐞嗘兂鐨勬満鍣ㄤ笂璇鋒厧閲嶈冭檻鍐嶅畨瑁呫?/p>
銆銆3.5 Emacs + GCC
銆銆鍓嶉潰璁茬殑澶ч儴鍒嗘槸Windows鐜涓嬬殑闆嗘垚寮鍙戠幆澧冦侺inux涓婄殑寮鍙戣呮洿鍊懼悜浜庝嬌鐢‥macs鏉ョ紪杈慍++鐨勬枃浠訛紝鐢∕akefile鏉ュ懡浠CC鍋氱紪璇戙傝櫧鐒剁湅涓婂幓姣旇緝鏉炬暎錛屼絾鏄繖浜涗笢瑗跨患鍚堣搗鏉ヨ繕鏄竴涓紑0鍙戠幆澧冦傚鏋滀綘鑳藉濞寸啛鐨勪嬌鐢ㄨ繖鏍風殑鐜鍐欑▼搴忥紝浣犵殑姘村鉤搴旇瓚沖鎸囧鎴戜滑鏉ュ啓榪欑瘒闄嬫枃浜嗐?/p>
銆銆3.6 Dev C++
銆銆GCC鏄竴涓緢濂界殑緙栬瘧鍣ㄣ傚湪Windows涓婄殑C++緙栬瘧鍣ㄤ竴鐩村拰鏍囧噯鏈夌潃涓孌佃窛紱葷殑鏃跺欙紝GCC灝辨槸涓涓Windows涓嬪紑鍙戣呮祦鍙f按鐨勭紪璇戝櫒銆侱ev-C++灝辨槸鑳藉璁〨CC璺戝湪Windows涓嬬殑宸ュ叿錛屼綔涓洪泦鎴愬紑鍙戠幆澧冿紝榪樻彁渚涗簡鍚屼笓涓欼DE鐩稿緹庣殑璇硶楂樹寒錛屼唬鐮佹彁紺猴紝璋冭瘯絳夊姛鑳姐傜敱浜庝嬌鐢―elphi寮鍙戯紝鍗犵敤鍐呭瓨灝戯紝閫熷害寰堝揩錛屾瘮杈冮傚悎杞婚噺綰х殑瀛︿範鍜屼嬌鐢ㄣ?/p>
銆銆3.7 Eclipse + CDT
銆銆Eclipse鍙槸榪戞潵澶у悕榧庨紟鐨勫紑鍙戝伐鍏楓傛渶鏂頒竴鏈熺殑Jolt澶у灝遍緇欎簡榪欎釜鏉板嚭鐨勭鐗┿傝鍏剁濂囨槸鍥犱負錛屽畠鏈韓鏄敤Java鍐欑殑錛屼絾鏄嫢鏈夋瘮涓鑸琂ava鍐欑殑紼嬪簭蹇緱澶氱殑閫熷害銆傝屼笖鍥犱負鍏跺熀浜庢彃浠剁粍瑁呬竴鍒囩殑鍘熷垯錛屼嬌寰楄兘澶熸湁CDT榪欐牱鐨勬彃浠舵妸Eclipse鍙樻垚涓涓狢/C++鐨勫紑鍙戠幆澧冦傚鏋滀綘涓鐩寸敤Eclipse鍐橨ava鐨勭▼搴忥紝涓嶅Θ鐢ㄥ畠浣撻獙涓涓婥++寮鍙戠殑涔愯叮銆?/p>
--------------------------------------------------------------------------------
銆銆4錛屽伐鍏?/p>
銆銆C++鐨勮緟鍔╁伐鍏風箒澶氾紝鎴戜滑鍒嗛棬鍒被鐨勪負澶у浣滀粙緇嶏細
銆銆4.1 鏂囨。綾?/p>
銆銆(1) Doxygen
銆銆鍙傝冪珯鐐癸細http://www.doxygen.org/
銆銆Doxygen鏄竴縐嶉傚悎C椋庢牸璇█錛堝C++銆丆銆両DL銆丣ava鐢氳嚦鍖呮嫭C#鍜孭HP錛夌殑銆佸紑鏀炬簮鐮佺殑銆佸熀浜庡懡浠よ鐨勬枃妗d駭鐢熷櫒銆?/p>
銆銆(2) C++2HTML
銆銆鍙傝冪珯鐐癸細http://www.bedaux.net/cpp2html/
銆銆鎶奀++浠g爜鍙樻垚璇硶楂樹寒鐨凥TML
銆銆(3) CodeColorizer
銆銆鍙傝冪珯鐐癸細http://www.chami.com/colorizer/
銆銆瀹冭兘鎶婂ソ鍑犵璇█鐨勬簮浠g爜鐫鑹蹭負HTML
銆銆(4) Doc-O-Matic
銆銆鍙傝冪珯鐐癸細http://www.doc-o-matic.com/
銆銆Doc-O_Matic涓轟綘鐨凜/C++錛孋++.net錛孌elphi/Pascal, VB.NET錛孋#鍜孞ava紼嬪簭鎴栬呯粍浠朵駭鐢熷噯紜殑鏂囨。銆侱oc-O-Matic浣跨敤婧愪唬鐮佷腑鐨勭鍙峰拰娉ㄩ噴浠ュ強澶栭儴鐨勬枃妗f枃浠跺垱寤轟笌嫻佽鐨勬枃妗f牱寮忎竴鑷寸殑鏂囨。銆?/p>
銆銆(5) DocVizor
銆銆鍙傝冪珯鐐癸細http://www.ucancode.net/Products/DocBuilder/Features.htm
銆銆DocVizor婊¤凍浜嗛潰鍚戝璞¤蔣浠跺紑鍙戣呯殑鍩烘湰瑕佹眰鈥斺斿畠璁╂垜浠兘澶熺湅鍒癈++宸ョ▼涓殑綾誨眰嬈$粨鏋勩侱ocVizor蹇熷湴浜х敓瀹屾暣鍙緵鎵撳嵃鐨勭被灞傛緇撴瀯鍥撅紝鍖呮嫭浠庣涓夋柟搴撲腑鏉ョ殑閭d簺綾伙紝闄ゆ涔嬪DocVizor榪樿兘浠庣被淇℃伅涓駭鐢烪TML鏂囦歡銆?/p>
銆銆(6) SourcePublisher C++
銆銆鍙傝冪珯鐐癸細http://www.scitools.com/sourcepublisher_c.html
銆銆緇欐簮浠g爜浜х敓鎻愪緵蹇熺洿瑙傜殑HTML鎶ヨ〃錛屽寘鎷唬鐮侊紝綾誨眰嬈$粨鏋勶紝璋冪敤鍜岃璋冪敤鏍戯紝鍖呭惈鍜岃鍖呭惈鏍戙傛敮鎸佸縐嶆搷浣滅郴緇熴?/p>
銆銆(7) Understand
銆銆鍙傝冪珯鐐癸細http://www.scitools.com/ucpp.html
銆銆鍒嗘瀽浠諱綍瑙勬ā鐨凜鎴栬匔++宸ョ▼錛屽府鍔╂垜浠洿濂界殑鐞嗚В浠ュ強緙栧啓鏂囨。銆?/p>
銆銆4.2 浠g爜綾?/p>
銆銆(1) CC-Rider
銆銆鍙傝冪珯鐐癸細http://www.cc-rider.com/
銆銆CC-Rider鏄敤浜嶤/C++紼嬪簭寮哄ぇ鐨勪唬鐮佸彲瑙嗗寲宸ュ叿錛岄氳繃浜や簰寮忔祻瑙堛佺紪杈戝強鑷姩鏂囦歡鏉ヤ績榪涚▼搴忕殑緇存寔鍜屽彂灞曘?/p>
銆銆(2) CodeInspect
銆銆鍙傝冪珯鐐癸細http://www.yokasoft.com/
銆銆涓縐嶆柊鐨凜/C++浠g爜鍒嗘瀽宸ュ叿銆傚畠媯鏌ユ垜浠殑婧愪唬鐮佹壘鍑洪潪鏍囧噯鐨勶紝鍙兘鐨勶紝浠ュ強鏅氱殑閿欒浠g爜銆?/p>
銆銆(3) CodeWizard
銆銆鍙傝冪珯鐐癸細http://www.parasoft.com/
銆銆鍏堣繘鐨凜/C++婧愪唬鐮佸垎鏋愬伐鍏鳳紝浣跨敤瓚呰繃500涓紪鐮佽鑼冭嚜鍔ㄥ寲鍦版爣鏄庡嵄闄╃殑錛屼絾鏄紪璇戝櫒涓嶈兘媯鏌ュ埌鐨勪唬鐮佺粨鏋勩?/p>
銆銆(4) C++ Validation Test Suites
銆銆鍙傝冪珯鐐癸細http://www.plumhall.com/suites.html
銆銆涓緇勭敤浜庢祴璇曠紪璇戝櫒鍜屽簱瀵逛簬鏍囧噯鍚誨悎紼嬪害鐨勪唬鐮佸簱銆?/p>
銆銆(5) CppRefactory
銆銆鍙傝冪珯鐐癸細http://cpptool.sourceforge.net/
銆銆CPPRefactory鏄竴涓嬌寰楀紑鍙戣呰兘澶熼噸鏋勪粬浠殑C++浠g爜鐨勭▼搴忋傜洰鐨勬槸浣垮緱C++浠g爜鐨勯噸鏋勮兘澶熷敖鍙兘鐨勬湁鏁堢巼鍜岀畝鍗曘?/p>
銆銆(6) Lzz
銆銆鍙傝冪珯鐐癸細http://www.lazycplusplus.com/
銆銆Lzz鏄竴涓嚜鍔ㄥ寲璁稿C++緙栫▼涓殑浣撳姏媧葷殑宸ュ叿銆傚畠鑳藉鑺傜渷鎴戜滑璁稿浜嬩歡騫朵笖浣垮緱緙栫爜鏇村姞鏈変箰瓚c傜粰鍑轟竴緋誨垪鐨勫0鏄庯紝Lzz浼氱粰鎴戜滑鍒涘緩澶存枃浠跺拰婧愭枃浠躲?/p>
銆銆(7) QA C++ Generation 2000
銆銆鍙傝冪珯鐐癸細http://www.programmingresearch.com/solutions/qacpp.htm
銆銆瀹冨叧娉ㄩ潰鍚戝璞$殑C++婧愪唬鐮侊紝瀵規湁鍏充簬璁捐錛屾晥鐜囷紝鍙?鎬э紝鍙淮鎶ゆх殑閮ㄥ垎鎻愬嚭璀﹀憡淇℃伅銆?/p>
銆銆(8) s-mail project - Java to C++DOL
銆銆鍙傝冪珯鐐癸細http://sadlocha.strefa.pl/s-mail/ja2dol.html
銆銆鎶奐ava婧愪唬鐮佺炕璇戜負鐩稿簲鐨凜++婧愪唬鐮佺殑鍛戒護琛屽伐鍏楓?/p>
銆銆(9) SNIP from Cleanscape Software International
銆銆鍙傝冪珯鐐癸細http://www.cleanscape.net/stdprod/snip/index.html
銆銆涓涓~騫崇紪鐮佸拰璁捐涔嬮棿娌熷鐨勬槗浜庝嬌鐢ㄧ殑C++寮鍙戝伐鍏鳳紝鑺傜渷澶ч噺緙栬緫鍜岃皟璇曠殑浜嬩歡錛屽畠榪樹嬌寰楀紑鍙戣呰兘澶熸寚瀹氳璁℃ā寮忎綔涓哄璞℃ā鍨嬶紝鑷姩浠庡璞℃ā鍨嬩腑浜х敓C++鐨勭被銆?/p>
銆銆(10) SourceStyler C++
銆銆鍙傝冪珯鐐癸細http://www.ochresoftware.com/
銆銆瀵笴/C++婧愪唬鐮佹彁渚涘畬鏁寸殑鏍煎紡鍖栧拰鎺掔増鎺у埗鐨勫伐鍏楓傛彁渚涘浜?5涓殑鏍煎紡鍖栭夐」浠ュ強瀹屽叏鏀寔ANSI C++銆?/p>
銆銆4.3 緙栬瘧綾?/p>
銆銆(1) Compilercache
銆銆鍙傝冪珯鐐癸細http://www.erikyyy.de/compilercache/
銆銆Compilercache鏄竴涓浣犵殑C鍜孋++緙栬瘧鍣ㄧ殑灝佽鑴氭湰銆傛瘡嬈℃垜浠繘琛岀紪璇戯紝灝佽鑴氭湰錛屾妸緙栬瘧鐨勭粨鏋滄斁鍏ョ紦瀛橈紝涓鏃︾紪璇戠浉鍚岀殑涓滆タ錛岀粨鏋滃皢浠庣紦瀛樹腑鍙栧嚭鑰屼笉鏄啀嬈$紪璇戙?/p>
銆銆(2) Ccache
銆銆鍙傝冪珯鐐癸細http://ccache.samba.org/
銆銆Ccache鏄竴涓紪璇戝櫒緙撳瓨銆傚畠浣跨敤璧鋒潵灝卞儚C/C++緙栬瘧鍣ㄧ殑緙撳瓨棰勫鐞嗗櫒錛岀紪璇戦熷害閫氬父鑳芥彁楂樻櫘閫氱紪璇戣繃紼嬬殑5~10鍊嶃?/p>
銆銆(3) Cmm (C++ with MultiMethods)
銆銆鍙傝冪珯鐐癸細http://www.op59.net/cmm/cmm-0.28/users.html
銆銆榪欐槸涓縐岰++璇█鐨勬墿灞曘傝鍏mm婧愪唬鐮佽緭鍑篊++鐨勬簮浠g爜錛屽姛鑳芥槸瀵笴++璇█娣誨姞浜嗗multimethod鐨勬敮鎸併?/p>
銆銆(4) The Frost Project
銆銆鍙傝冪珯鐐癸細http://frost.flewid.de/
銆銆Forst浣垮緱浣犺兘澶熷湪C++紼嬪簭涓儚鍘熺敓鐨凜++鐗規т竴鏍蜂嬌鐢╩ultimethod浠ュ強铏氬嚱鏁板弬鏁般傚畠鏄竴涓紪璇戝櫒鐨勫澹熾?/p>
銆銆4.4 嫻嬭瘯鍜岃皟璇曠被
銆銆(1) CPPUnit
銆銆CppUnit 鏄釜鍩轟簬 LGPL 鐨勫紑婧愰」鐩紝鏈鍒濈増鏈Щ妞嶈嚜 JUnit錛屾槸涓涓潪甯鎬紭縐鐨勫紑婧愭祴璇曟鏋躲侰ppUnit 鍜?JUnit 涓鏍蜂富瑕佹濇兂鏉ユ簮浜庢瀬闄愮紪紼嬨備富瑕佸姛鑳藉氨鏄鍗曞厓嫻嬭瘯榪涜綆$悊錛屽茍鍙繘琛岃嚜鍔ㄥ寲嫻嬭瘯銆?br />
銆銆(2) C++Test
銆銆鍙傝冪珯鐐癸細http://www.parasoft.com/
銆銆C++ Test鏄竴涓崟鍏冩祴璇曞伐鍏鳳紝瀹冭嚜鍔ㄥ寲浜咰鍜孋++綾伙紝鍑芥暟鎴栬呯粍浠剁殑嫻嬭瘯銆?/p>
銆銆(3) Cantata++
銆銆鍙傝冪珯鐐癸細http://www.iplbath.com/products/tools/pt400.shtml
銆銆璁捐鐨勭洰鐨勬槸涓轟簡婊¤凍鍦ㄥ悎鐞嗙殑緇忔祹寮閿涓嬩嬌鐢ㄨ繖涓伐鍏峰彲浠ヨ寮鍙戝伐紼嬪笀寮灞曞崟鍏冩祴璇曞拰闆嗘垚嫻嬭瘯鐨勯渶姹?
銆銆(4) Purify
銆銆鍙傝冪珯鐐癸細http://www-900.ibm.com/cn/software/rational/products/purif
yplus/index.shtml
銆銆IBM Rational PurifyPlus鏄竴濂楀畬鏁寸殑榪愯鏃跺垎鏋愬伐鍏鳳紝鏃ㄥ湪鎻愰珮搴旂敤紼嬪簭鐨勫彲*鎬у拰鎬ц兘銆侾urifyPlus灝嗗唴瀛橀敊璇拰娉勬紡媯嫻嬨佸簲鐢ㄧ▼搴忔ц兘鎻忚堪銆佷唬鐮佽鐩栧垎鏋愮瓑鍔熻兘緇勫悎鍦ㄤ竴涓崟涓銆佸畬鏁寸殑宸ュ叿鍖呬腑銆?/p>
銆銆(5) BoundsChecker
銆銆BoundsChecker鏄竴涓狢++榪愯鏃墮敊璇嫻嬪拰璋冭瘯宸ュ叿銆傚畠閫氳繃鍦╒isual Studio鍐呰嚜鍔ㄥ寲璋冭瘯榪囩▼鍔犻熷紑鍙戝茍涓旂緝鐭笂甯傜殑鍛ㄦ湡銆侭oundsChecker鎻愪緵娓呮錛岃緇嗙殑紼嬪簭閿欒鍒嗘瀽錛岃澶氭槸瀵笴++鐙湁鐨勫茍涓斿湪static錛宻tack鍜宧eap鍐呭瓨涓嫻嬪拰璇婃柇閿欒錛屼互鍙婂彂鐜板唴瀛樺拰璧勬簮鐨勬硠婕忋傘銆
銆銆(6) Insure++
銆銆鍙傝冪珯鐐癸細http://www.parasoft.com/
銆銆涓涓嚜鍔ㄥ寲鐨勮繍琛屾椂紼嬪簭嫻嬭瘯宸ュ叿錛屾鏌ラ毦浠ュ療瑙夌殑閿欒,濡傚唴瀛樿鐩栵紝鍐呭瓨娉勬紡錛屽唴瀛樺垎閰嶉敊璇紝鍙橀噺鍒濆鍖栭敊璇紝鍙橀噺瀹氫箟鍐茬獊錛屾寚閽堥敊璇紝搴撻敊璇紝閫昏緫閿欒鍜岀畻娉曢敊璇瓑銆?/p>
銆銆(7) GlowCode
銆銆鍙傝冪珯鐐癸細http://www.glowcode.com/
銆銆GlowCode鍖呮嫭鍐呭瓨娉勬紡媯鏌ワ紝code profiler錛屽嚱鏁拌皟鐢ㄨ窡韙瓑鍔熻兘銆傜粰C++寮鍙戣呮彁渚涘畬鏁寸殑閿欒璇婃柇錛屽拰榪愯鏃舵ц兘鍒嗘瀽宸ュ叿鍖呫?/p>
銆銆(8) Stack Spy
銆銆鍙傝冪珯鐐癸細http://www.imperioustech.com/
銆銆瀹冭兘鎹曟崏stack corruption, stack over run, stack overflow絳夋湁鍏蟲爤鐨勯敊璇?/p>
------------------------------------------------------------------------
銆5錛屽簱
銆銆鍦–++涓紝搴撶殑鍦頒綅鏄潪甯擱珮鐨勩侰++涔嬬埗 Bjarne Stroustrup鍏堢敓澶氭琛ㄧず浜嗚璁″簱鏉ユ墿鍏呭姛鑳借濂借繃璁捐鏇村鐨勮娉曠殑璦璁恒傜幇瀹炰腑錛孋++鐨勫簱闂ㄧ被綣佸錛岃В鍐崇殑闂涔熸槸鏋佸叾騫挎硾錛屽簱浠庤交閲忕駭鍒伴噸閲忕駭鐨勯兘鏈夈備笉灝戦兘鏄浜虹溂鐣屽ぇ寮錛屼害鎴栨槸鏈涜岀敓鍙圭殑鎬濈淮鏉頒綔銆傜敱浜庡簱鐨勬暟閲忛潪甯稿簽澶э紝鑰屼笖闄愪簬絎旇呮按騫籌紝鍏朵腑寰堝騫朵笉浜嗚В銆傛墍浠ユ枃涓墍鎻愮殑涓浜涘簱閮芥槸姣旇緝钁楀悕鐨勫ぇ鍨嬪簱銆?/p>
銆銆5.1 鏍囧噯搴?/p>
銆銆鏍囧噯搴撲腑鎻愪緵浜咰++紼嬪簭鐨勫熀鏈鏂姐傝櫧鐒禖++鏍囧噯搴撻殢鐫C++鏍囧噯鎶樿吘浜嗚澶氬勾錛岀洿鍒版爣鍑嗙殑鍑哄彴鎵嶆寮忓畾鍨嬶紝浣嗘槸鍦ㄦ爣鍑嗗簱鐨勫疄鐜頒笂鍗村緢浠や漢嬈f叞寰楃湅鍒板縐嶅疄鐜幫紝騫朵笖宸茶瀹炶返璇佹槑涓烘湁宸ヤ笟綰у埆寮哄害鐨勪匠浣溿?/p>
銆銆(1) Dinkumware C++ Library
銆銆鍙傝冪珯鐐癸細http://www.dinkumware.com/
銆銆P.J. Plauger緙栧啓鐨勯珮鍝佽川鐨勬爣鍑嗗簱銆侾.J. Plauger鍗氬+鏄疍r. Dobb's紼嬪簭璁捐鏉板嚭濂栫殑鑾峰緱鑰呫傚叾緙栧啓鐨勫簱闀挎湡琚玀icrosoft閲囩敤錛屽茍涓旀渶榪態orland涔熷彇寰椾簡鍏禣EM鐨刲icense錛屽湪鍏禖/C++鐨勪駭鍝佷腑閲囩敤Dinkumware鐨勫簱銆?/p>
銆銆(2) RogueWave Standard C++ Library
銆銆鍙傝冪珯鐐癸細http://www.roguewave.com/
銆銆榪欎釜搴撳湪Borland C++ Builder鐨勬棭鏈熺増鏈腑鏇劇粡琚噰鐢紝鍚庢潵琚叾浠栫殑搴撶粰鏇挎崲浜嗐傜瑪鑰呬笉鎺ㄨ崘浣跨敤銆?/p>
銆銆(3) SGI STL
銆銆鍙傝冪珯鐐癸細http://www.roguewave.com/
銆銆SGI鍏徃鐨凜++鏍囧噯妯$増搴撱?/p>
銆銆(4) STLport
銆銆鍙傝冪珯鐐癸細http://www.stlport.org/
銆銆SGI STL搴撶殑璺ㄥ鉤鍙板彲縐繪鐗堟湰銆?/p>
銆銆5.2 鈥滃噯鈥濇爣鍑嗗簱 - Boost
銆銆鍙傝冪珯鐐癸細http://www.boost.org/
銆銆鍥藉唴闀滃儚錛?a >http://www.c-view.org/tech/lib/boost/index.htm
銆銆Boost搴撴槸涓涓粡榪囧崈閿ょ櫨鐐箋佸彲縐繪銆佹彁渚涙簮浠g爜鐨凜++搴擄紝浣滀負鏍囧噯搴撶殑鍚庡錛屾槸C++鏍囧噯鍖栬繘紼嬬殑鍙戝姩鏈轟箣涓銆?Boost搴撶敱C++鏍囧噯濮斿憳浼氬簱宸ヤ綔緇勬垚鍛樺彂璧鳳紝鍦–++紺懼尯涓獎鍝嶇敋澶э紝鍏舵垚鍛樺凡榪?000浜恒?Boost搴撲負鎴戜滑甯︽潵浜嗘渶鏂般佹渶閰楓佹渶瀹炵敤鐨勬妧鏈紝鏄笉鎶樹笉鎵g殑鈥滃噯鈥濇爣鍑嗗簱銆?/p>
銆銆Boost涓瘮杈冩湁鍚嶆皵鐨勬湁榪欎箞鍑犱釜搴擄細
銆銆Regex
銆銆姝e垯琛ㄨ揪寮忓簱
銆銆Spirit
銆銆LL parser framework錛岀敤C++浠g爜鐩存帴琛ㄨ揪EBNF
銆銆Graph
銆銆鍥劇粍浠跺拰綆楁硶
銆銆Lambda
銆銆鍦ㄨ皟鐢ㄧ殑鍦版柟瀹氫箟鐭皬鍖垮悕鐨勫嚱鏁板璞★紝寰堝疄鐢ㄧ殑functional鍔熻兘
銆銆concept check
銆銆媯鏌ユ硾鍨嬬紪紼嬩腑鐨刢oncept
聽
銆銆Mpl
銆銆鐢ㄦā鏉垮疄鐜扮殑鍏冪紪紼嬫鏋?/p>
聽
銆銆Thread
銆銆鍙Щ妞嶇殑C++澶氱嚎紼嬪簱
聽
銆銆Python
銆銆鎶奀++綾誨拰鍑芥暟鏄犲皠鍒癙ython涔嬩腑
銆銆Pool
銆銆鍐呭瓨姹犵鐞?/p>
聽
銆銆smart_ptr
銆銆5涓櫤鑳芥寚閽堬紝瀛︿範鏅鴻兘鎸囬拡蹇呰錛屼竴浠戒笉閿欑殑鍙傝冩槸鏉ヨ嚜CUJ鐨勬枃绔狅細
銆銆Smart Pointers in Boost錛屽摝錛岃繖綃囨枃绔犲彲浠ユ煡鍒幫紝CUJ鏄彁渚涘湪綰挎祻瑙堢殑銆備腑鏂囩増瑙佺瑪鑰呭湪銆奃r. Dobb's Journal杞歡鐮斿彂鏉傚織銆嬬7杈戜笂鐨勮瘧鏂囥?/p>
銆銆Boost鎬諱綋鏉ヨ鏄疄鐢ㄤ環鍊煎緢楂橈紝璐ㄩ噺寰堥珮鐨勫簱銆傚茍涓旂敱浜庡叾瀵硅法騫沖彴鐨勫己璋冿紝瀵規爣鍑咰++鐨勫己璋冿紝鏄紪鍐欏鉤鍙版棤鍏籌紝鐜頒唬C++鐨勫紑鍙戣呭繀澶囩殑宸ュ叿銆備絾鏄疊oost涓篃鏈夊緢澶氭槸瀹為獙鎬ц川鐨勪笢瑗匡紝鍦ㄥ疄闄呯殑寮鍙戜腑瀹炵敤闇瑕佽皚鎱庛傚茍涓斿緢澶欱oost涓殑搴撳姛鑳藉牚縐板璇█鍔熻兘鐨勬墿灞曪紝鍏舵瀯閫犵敤灝界簿宸х殑鎵嬫硶錛屼笉瑕佽錘鐒剁殑鑺辮垂鏃墮棿鐮旇銆侭oost鍙﹀涓闈紝姣斿Graph榪欐牱鐨勫簱鍒欐槸鍏鋒湁宸ヤ笟寮哄害錛岀粨鏋勮壇濂斤紝闈炲父鍊煎緱鐮旇鐨勭簿鍝佷唬鐮侊紝騫朵笖涔熷彲浠ユ斁蹇冪殑鍦ㄤ駭鍝佷唬鐮佷腑澶氬鍒╃敤銆?/p>
銆銆5.3 GUI
銆銆鍦ㄤ紬澶欳++鐨勫簱涓紝GUI閮ㄥ垎鐨勫簱綆楁槸姣旇緝綣佽崳錛屼篃姣旇緝寮曚漢娉ㄧ洰鐨勩傚湪瀹為檯寮鍙戜腑錛孏UI搴撶殑閫夋嫨涔熸槸闈炲父閲嶈鐨勪竴浠朵簨鎯咃紝涓嬮潰鎴戜滑緇艱堪涓涓嬪彲閫夋嫨鐨凣UI搴擄紝鍚勮嚜鐨勭壒鐐逛互鍙婄浉鍏沖伐鍏風殑鏀寔銆?/p>
銆銆(1) MFC
銆銆澶у悕榧庨紟鐨勫井杞熀紜綾誨簱錛圡icrosoft Foundation Class錛夈傚ぇ鍑″榪嘨C++鐨勪漢閮藉簲璇ョ煡閬撹繖涓簱銆傝櫧鐒朵粠鎶鏈搴﹁錛孧FC鏄笉澶ф紓浜殑錛屼絾鏄畠鏋勫緩浜嶹indows API 涔嬩笂錛岃兘澶熶嬌紼嬪簭鍛樼殑宸ヤ綔鏇村鏄?緙栫▼鏁堢巼楂橈紝鍑忓皯浜嗗ぇ閲忓湪寤虹珛 Windows 紼嬪簭鏃跺繀欏葷紪鍐欑殑浠g爜錛屽悓鏃跺畠榪樻彁渚涗簡鎵鏈変竴鑸?C++ 緙栫▼鐨勪紭鐐癸紝渚嬪緇ф壙鍜屽皝瑁呫侻FC 緙栧啓鐨勭▼搴忓湪鍚勪釜鐗堟湰鐨刉indows鎿嶄綔緋葷粺涓婃槸鍙Щ妞嶇殑錛屼緥濡傦紝鍦╓indows 3.1涓嬬紪鍐欑殑浠g爜鍙互寰堝鏄撳湴縐繪鍒?Windows NT 鎴?Windows 95 涓娿備絾鏄湪鏈榪戝彂灞曚互鍙婂畼鏂規敮鎸佷笂鏃ユ笎鍔垮井銆?/p>
銆銆(2) QT
銆銆鍙傝冪綉绔欙細http://www.trolltech.com/
銆銆Qt鏄疶rolltech鍏徃鐨勪竴涓騫沖彴鐨凜++鍥懼艦鐢ㄦ埛鐣岄潰搴旂敤紼嬪簭妗嗘灦銆傚畠鎻愪緵緇欏簲鐢ㄧ▼搴忓紑鍙戣呭緩绔嬭壓鏈駭鐨勫浘褰㈢敤鎴風晫闈㈡墍闇鐨勬墍鐢ㄥ姛鑳姐俀t鏄畬鍏ㄩ潰鍚戝璞$殑寰堝鏄撴墿灞曪紝騫朵笖鍏佽鐪熸鍦扮粍浠剁紪紼嬨傝嚜浠?996騫存棭浜涙椂鍊欙紝Qt榪涘叆鍟嗕笟棰嗗煙錛屽畠宸茬粡鎴愪負鍏ㄤ笘鐣岃寖鍥村唴鏁板崈縐嶆垚鍔熺殑搴旂敤紼嬪簭鐨勫熀紜銆俀t涔熸槸嫻佽鐨凩inux妗岄潰鐜KDE 鐨勫熀紜錛屽悓鏃跺畠榪樻敮鎸乄indows銆丮acintosh銆乁nix/X11絳夊縐嶅鉤鍙般?/p>
銆銆(3) WxWindows
銆銆鍙傝冪綉绔欙細http://www.wxwindows.org/
銆銆璺ㄥ鉤鍙扮殑GUI搴撱傚洜涓哄叾綾誨眰嬈℃瀬鍍廙FC錛屾墍浠ユ湁鏂囩珷浠嬬粛浠嶮FC鍒癢xWindows鐨勪唬鐮佺Щ妞嶄互瀹炵幇璺ㄥ鉤鍙扮殑鍔熻兘銆傞氳繃澶氬勾鐨勫紑鍙戜篃鏄竴涓棩瓚嬪畬鍠勭殑GUI搴擄紝鏀寔鍚屾牱涓嶅急浜庡墠闈袱涓簱銆傚茍涓旀槸瀹屽叏寮鏀炬簮浠g爜鐨勩傛柊榪戠殑C++ Builder X鐨凣UI璁捐鍣ㄥ氨鏄熀浜庤繖涓簱鐨勩?/p>
銆銆(4) Fox
銆銆鍙傝冪綉绔欙細http://www.fox-toolkit.org/
銆銆寮鏀炬簮浠g爜鐨凣UI搴撱備綔鑰呬粠鑷繁浜茶韓鐨勫紑鍙戠粡楠屼腑寰楀嚭浜嗕竴涓悊鎯崇殑GUI搴撳簲璇ユ槸浠涔堟牱瀛愮殑鎰熷彈鍑哄彂錛屼粠鑰屽紑濮嬩簡瀵硅繖涓簱鐨勫紑鍙戙傛湁鍏磋叮鐨勫彲浠ュ皾璇曚竴涓嬨?/p>
銆銆(5) WTL
銆銆鍩轟簬ATL鐨勪竴涓簱銆傚洜涓轟嬌鐢ㄤ簡澶ч噺ATL鐨勮交閲忕駭鎵嬫硶錛屾ā鏉跨瓑鎶鏈紝鍦ㄤ唬鐮佸昂瀵革紝浠ュ強閫熷害浼樺寲鏂歸潰鍋氬緱闈炲父鍒頒綅銆備富瑕侀潰鍚戠殑浣跨敤緹や綋鏄紑鍙慍OM杞婚噺綰т緵緗戠粶涓嬭澆鐨勫彲瑙嗗寲鎺т歡鐨勫紑鍙戣呫?/p>
銆銆(6) GTK
銆銆鍙傝冪綉绔欙細http://gtkmm.sourceforge.net/
銆銆GTK鏄竴涓ぇ鍚嶉紟榧庣殑C鐨勫紑婧怗UI搴撱傚湪Linux涓栫晫涓湁Gnome榪欐牱鐨勬潃鎵嬪簲鐢ㄣ傝孏TK灝辨槸榪欎釜搴撶殑C++灝佽鐗堟湰銆?/p>
銆銆5.4 緗戠粶閫氫俊
銆銆(1) ACE
銆銆鍙傝冪綉绔欙細http://www.cs.wustl.edu/~schmidt/ACE.html
銆銆C++搴撶殑浠h〃錛岃秴閲嶉噺綰х殑緗戠粶閫氫俊寮鍙戞鏋躲侫CE鑷傞厤閫氫俊鐜錛圓daptiveCommunication Environment錛夋槸鍙互鑷敱浣跨敤銆佸紑鏀炬簮浠g爜鐨勯潰鍚戝璞℃鏋訛紝鍦ㄥ叾涓疄鐜頒簡璁稿鐢ㄤ簬騫跺彂閫氫俊杞歡鐨勬牳蹇冩ā寮忋侫CE鎻愪緵浜嗕竴緇勪赴瀵岀殑鍙鐢–++鍖呰澶栬錛圵rapper Facade錛夊拰妗嗘灦緇勪歡錛屽彲璺ㄨ秺澶氱騫沖彴瀹屾垚閫氱敤鐨勯氫俊杞歡浠誨姟錛屽叾涓寘鎷細浜嬩歡澶氳礬鍒嗙鍜屼簨浠跺鐞嗗櫒鍒嗘淳銆佷俊鍙峰鐞嗐佹湇鍔″垵濮嬪寲銆佽繘紼嬮棿閫?br />淇°佸叡浜唴瀛樼鐞嗐佹秷鎭礬鐢便佸垎甯冨紡鏈嶅姟鍔ㄦ侊紙閲嶏級閰嶇疆銆佸茍鍙戞墽琛屽拰鍚屾錛岀瓑絳夈?/p>
銆銆(2) StreamModule
銆銆鍙傝冪綉绔欙細http://www.omnifarious.org/StrMod/
銆銆璁捐鐢ㄤ簬綆鍖栫紪鍐欏垎甯冨紡紼嬪簭鐨勫簱銆傚皾璇曠潃浣垮緱緙栧啓澶勭悊寮傛琛屼負鐨勭▼搴忔洿瀹規槗錛岃屼笉鏄敤鍚屾鐨勫澹沖寘璧峰紓姝ョ殑鏈川銆?/p>
銆銆(3) SimpleSocket
銆銆鍙傝冪綉绔欙細http://home.hetnet.nl/~lcbokkers/simsock.htm
銆銆榪欎釜綾誨簱璁╃紪鍐欏熀浜巗ocket鐨勫鎴?鏈嶅姟鍣ㄧ▼搴忔洿鍔犲鏄撱?/p>
銆銆(4) A Stream Socket API for C++
銆銆鍙傝冪綉绔欙細http://www.pcs.cnu.edu/~dgame/sockets/socketsC++/sockets.h
tml
銆銆鍙堜竴涓Socket鐨勫皝瑁呭簱銆?/p>
銆銆5.5 XML
銆銆(1) Xerces
銆銆鍙傝冪綉绔欙細http://xml.apache.org/xerces-c/
銆銆Xerces-C++ 鏄竴涓潪甯稿仴澹殑XML瑙f瀽鍣紝瀹冩彁渚涗簡楠岃瘉錛屼互鍙奡AX鍜孌OM API銆俋ML楠岃瘉鍦ㄦ枃妗g被鍨嬪畾涔?Document Type Definition錛孌TD)鏂歸潰鏈夊緢濂界殑鏀寔錛屽茍涓斿湪2001騫?2鏈堝鍔犱簡鏀寔W3C XML Schema 鐨勫熀鏈畬鏁寸殑寮鏀炬爣鍑嗐?/p>
銆銆(2) XMLBooster
銆銆鍙傝冪綉绔欙細http://www.xmlbooster.com/
銆銆榪欎釜搴撻氳繃浜х敓鐗瑰埗鐨刾arser鐨勫姙娉曟瀬澶х殑鎻愰珮浜哫ML瑙f瀽鐨勯熷害錛屽茍涓旇兘澶熶駭鐢熺浉搴旂殑GUI紼嬪簭鏉ヤ慨鏀硅繖涓猵arser銆傚湪DOM鍜孲AX涓ゅぇ涓繪祦XML瑙f瀽鍔炴硶涔嬪鎻愪緵浜嗗彟澶栦竴涓彲琛岀殑瑙e喅鏂規銆?/p>
銆銆(3) Pull Parser
銆銆鍙傝冪綉绔欙細http://www.extreme.indiana.edu/xgws/xsoap/xpp/
銆銆榪欎釜搴撻噰鐢╬ull鏂規硶鐨刾arser銆傚湪姣忎釜SAX鐨刾arser搴曞眰閮芥湁涓涓猵ull鐨刾arser錛岃繖涓獂pp鎶婅繖灞傛毚闇插嚭鏉ョ洿鎺ョ粰澶у浣跨敤銆傚湪瑕佸厖鍒嗚冭檻閫熷害鐨勬椂鍊欏煎緱灝濊瘯銆?br />
銆銆(4) Xalan
銆銆鍙傝冪綉绔欙細http://xml.apache.org/xalan-c/
銆銆Xalan鏄竴涓敤浜庢妸XML鏂囨。杞崲涓篐TML錛岀函鏂囨湰鎴栬呭叾浠朮ML綾誨瀷鏂囨。鐨刋SLT澶勭悊鍣ㄣ?/p>
銆銆(5) CMarkup
銆銆鍙傝冪綉绔欙細http://www.firstobject.com/xml.htm
銆銆榪欐槸涓縐嶄嬌鐢‥DOM鐨刋ML瑙f瀽鍣ㄣ傚湪寰堝鎬濊礬涓婇潰闈炲父鐏墊椿瀹炵敤銆傚煎緱澶у鍦―OM鍜孲AX涔嬪瀵繪眰涓鐐圭伒鎰熴?/p>
銆銆(6) libxml++
銆銆http://libxmlplusplus.sourceforge.net/
銆銆libxml++鏄钁楀悕鐨刲ibxml XML瑙f瀽鍣ㄧ殑C++灝佽鐗堟湰
銆銆5.6 縐戝璁$畻
銆銆(1) Blitz++
銆銆鍙傝冪綉绔欙細http://www.oonumerics.org/blitz/
銆銆Blitz++ 鏄竴涓珮鏁堢巼鐨勬暟鍊艱綆楀嚱鏁板簱錛屽畠鐨勮璁$洰鐨勬槸甯屾湜寤虹珛涓濂楁棦鍏峰儚C++ 涓鏍鋒柟渚匡紝鍚屾椂鍙堟瘮Fortran閫熷害鏇村揩鐨勬暟鍊艱綆楃幆澧冦傞氬父錛岀敤C++鎵鍐欏嚭鐨勬暟鍊肩▼搴忥紝姣?Fortran鎱?0%宸﹀彸錛屽洜姝litz++姝f槸瑕佹敼鎺夎繖涓己鐐廣傛柟娉曟槸鍒╃敤C++鐨則emplate鎶鏈紝紼嬪簭鎵ц鐢氳嚦鍙互姣擣ortran鏇村揩銆侭litz++鐩墠浠嶅湪鍙戝睍涓紝瀵逛簬甯歌鐨凷VD錛孎FTs錛孮MRES絳夊父瑙佺殑綰挎т唬鏁版柟娉曞茍涓嶆彁渚涳紝涓嶈繃浣跨敤鑰呭彲浠ュ緢瀹規槗鍦板埄鐢˙litz++鎵鎻愪緵鐨勫嚱鏁版潵鏋勫緩銆?/p>
銆銆(2) POOMA
銆銆鍙傝冪綉绔欙細http://www.codesourcery.com/pooma/pooma
銆銆POOMA鏄竴涓厤璐圭殑楂樻ц兘鐨凜++搴擄紝鐢ㄤ簬澶勭悊騫惰寮忕瀛﹁綆椼侾OOMA鐨勯潰鍚戝璞¤璁℃柟渚夸簡蹇熺殑紼嬪簭寮鍙戯紝瀵瑰茍琛屾満鍣ㄨ繘琛屼簡浼樺寲浠ヨ揪鍒版渶楂樼殑鏁堢巼錛屾柟渚垮湪宸ヤ笟鍜岀爺絀剁幆澧冧腑浣跨敤銆?/p>
銆銆(3) MTL
銆銆鍙傝冪綉绔欙細http://www.osl.iu.edu/research/mtl/
銆銆Matrix Template Library(MTL)鏄竴涓珮鎬ц兘鐨勬硾鍨嬬粍浠跺簱錛屾彁渚涗簡鍚勭鏍煎紡鐭╅樀鐨勫ぇ閲忕嚎鎬т唬鏁版柟闈㈢殑鍔熻兘銆傚湪鏌愪簺搴旂敤浣跨敤楂樻ц兘緙栬瘧鍣ㄧ殑鎯呭喌涓嬶紝姣斿Intel鐨勭紪璇戝櫒錛屼粠浜х敓鐨勬眹緙栦唬鐮佸彲浠ョ湅鍑哄叾涓庢墜鍐欏嚑涔庢病鏈変袱鏍風殑鏁堣兘銆?/p>
銆銆(4) CGAL
銆銆鍙傝冪綉绔欙細http://www.cgal.org/
銆銆Computational Geometry Algorithms Library鐨勭洰鐨勬槸鎶婂湪璁$畻鍑犱綍鏂歸潰鐨勫ぇ閮ㄥ垎閲嶈鐨勮В鍐蟲柟妗堝拰鏂規硶浠++搴撶殑褰㈠紡鎻愪緵緇欏伐涓氬拰瀛︽湳鐣岀殑鐢ㄦ埛銆?/p>
銆銆5.7 娓告垙寮鍙?/p>
銆銆(1) Audio/Video 3D C++ Programming Library
銆銆鍙傝冪綉绔欙細http://www.galacticasoftware.com/products/av/
銆銆AV3D鏄竴涓法騫沖彴錛岄珮鎬ц兘鐨凜++搴撱備富瑕佺殑鐗規ф槸鎻愪緵3D鍥懼艦錛屽0鏁堟敮鎸侊紙SB,浠ュ強S3M錛夛紝鎺у埗鎺ュ彛錛堥敭鐩橈紝榧犳爣鍜岄仴鎰燂級錛孹MS銆?/p>
銆銆(2) KlayGE
銆銆鍙傝冪綉绔欙細http://home.g365.net/enginedev/
銆銆鍥藉唴娓告垙寮鍙戦珮鎵嬭嚜宸辯敤C++寮鍙戠殑娓告垙寮曟搸銆侹layGE鏄竴涓紑鏀炬簮浠g爜銆佽法騫沖彴鐨勬父鎴忓紩鎿庯紝騫朵嬌鐢≒ython浣滆剼鏈璦銆侹layGE鍦↙GPL鍗忚涓嬪彂琛屻傛劅璋㈤練鏁忔晱鍏堢敓涓轟腑鍥芥父鎴忓紑鍙戜簨涓氭墍鍋氬嚭鐨勮礎鐚?/p>
銆銆(3) OGRE
銆銆鍙傝冪綉绔欙細http://www.ogre3d.org/
銆銆OGRE錛堥潰鍚戝璞$殑鍥懼艦娓叉煋寮曟搸錛夋槸鐢–++寮鍙戠殑錛屼嬌鐢ㄧ伒媧葷殑闈㈠悜瀵硅薄3D寮曟搸銆傚畠鐨勭洰鐨勬槸璁╁紑鍙戣呰兘鏇存柟渚垮拰鐩存帴鍦板紑鍙戝熀浜?D紜歡璁懼鐨勫簲鐢ㄧ▼搴忔垨娓告垙銆傚紩鎿庝腑鐨勭被搴撳鏇村簳灞傜殑緋葷粺搴擄紙濡傦細Direct3D鍜孫penGL錛夌殑鍏ㄩ儴浣跨敤緇嗚妭榪涜浜嗘娊璞★紝騫舵彁渚涗簡鍩轟簬鐜板疄涓栫晫瀵硅薄鐨勬帴鍙e拰鍏跺畠綾匯?/p>
銆銆5.8 綰跨▼
銆銆(1) C++ Threads
銆銆鍙傝冪綉绔欙細http://threads.sourceforge.net/
銆銆榪欎釜搴撶殑鐩爣鏄粰紼嬪簭鍛樻彁渚涙槗浜庝嬌鐢ㄧ殑綾伙紝榪欎簺綾昏緇ф壙浠ユ彁渚涘湪Linux鐜涓緢闅劇湅鍒扮殑澶ч噺鐨勭嚎紼嬫柟闈㈢殑鍔熻兘銆?/p>
銆銆(2) ZThreads
銆銆鍙傝冪綉绔欙細http://zthread.sourceforge.net/
銆銆涓涓厛榪涚殑闈㈠悜瀵硅薄錛岃法騫沖彴鐨凜++綰跨▼鍜屽悓姝ュ簱銆?br />
銆銆5.9 搴忓垪鍖?/p>
銆銆(1) s11n
銆銆鍙傝冪綉绔欙細http://s11n.net/
銆銆涓涓熀浜嶴TL鐨凜++搴擄紝鐢ㄤ簬搴忓垪鍖朠OD錛孲TL瀹瑰櫒浠ュ強鐢ㄦ埛瀹氫箟鐨勭被鍨嬨?/p>
銆銆(2) Simple XML Persistence Library
銆銆鍙傝冪綉绔欙細http://sxp.sourceforge.net/
銆銆榪欐槸涓涓妸瀵硅薄搴忓垪鍖栦負XML鐨勮交閲忕駭鐨凜++搴撱?/p>
銆銆5.10 瀛楃涓?/p>
銆銆(1) C++ Str Library
銆銆鍙傝冪綉绔欙細http://www.utilitycode.com/str/
銆銆鎿嶄綔瀛楃涓插拰瀛楃鐨勫簱錛屾敮鎸乄indows鍜屾敮鎸乬cc鐨勫縐嶅鉤鍙般傛彁渚涢珮搴︿紭鍖栫殑浠g爜錛屽茍涓旀敮鎸佸綰跨▼鐜鍜孶nicode錛屽悓鏃惰繕鏈夋鍒欒〃杈懼紡鐨勬敮鎸併?/p>
銆銆(2) Common Text Transformation Library
銆銆鍙傝冪綉绔欙細http://cttl.sourceforge.net/
銆銆榪欐槸涓涓В鏋愬拰淇敼STL瀛楃涓茬殑搴撱侰TTL substring綾誨彲浠ョ敤鏉ユ瘮杈冿紝鎻掑叆錛屾浛鎹互鍙婄敤EBNF鐨勮娉曡繘琛岃В鏋愩?/p>
銆銆(3) GRETA
銆銆鍙傝冪綉绔欙細http://research.microsoft.com/projects/greta/
銆銆榪欐槸鐢卞井杞爺絀墮櫌鐨勭爺絀朵漢鍛樺紑鍙戠殑澶勭悊姝e垯琛ㄨ揪寮忕殑搴撱傚湪灝忓瀷鍖歸厤鐨勬儏鍐典笅鏈夐潪甯鎬紭縐鐨勮〃鐜般?/p>
銆銆5.11 緇煎悎
銆銆(1) P::Classes
銆銆鍙傝冪綉绔欙細http://pclasses.com/
銆銆涓涓珮搴﹀彲縐繪鐨凜++搴旂敤紼嬪簭妗嗘灦銆傚綋鍓嶅叧娉ㄧ被鍨嬪拰綰跨▼瀹夊叏鐨剆ignal/slot鏈哄埗錛宨/o緋葷粺鍖呮嫭鍩轟簬鎻掍歡鐨勭綉緇滃崗璁忔槑鐨刬/o鏋舵瀯錛屽熀浜庢彃浠剁殑搴旂敤紼嬪簭娑堟伅鏃ュ織妗嗘灦錛岃闂畇ql鏁版嵁搴撶殑綾葷瓑絳夈?/p>
銆銆(2) ACDK - Artefaktur Component Development Kit
銆銆鍙傝冪綉绔欙細http://acdk.sourceforge.net/
銆銆榪欐槸涓涓鉤鍙版棤鍏崇殑C++緇勪歡妗嗘灦錛岀被浼間簬Java鎴栬?NET涓殑妗嗘灦錛堝弽灝勬満鍒訛紝綰跨▼錛孶nicode錛屽簾鏂欐敹闆嗭紝I/O錛岀綉緇滐紝瀹炵敤宸ュ叿錛孹ML錛岀瓑絳夛級錛屼互鍙婂Java, Perl, Python, TCL, Lisp, COM 鍜?CORBA鐨勯泦鎴愩?/p>
銆銆(3) dlib C++ library
銆銆鍙傝冪綉绔欙細http://www.cis.ohio-state.edu/~kingd/dlib/
銆銆鍚勭鍚勬牱鐨勭被鐨勪竴涓患鍚堛傚ぇ鏁存暟錛孲ocket錛岀嚎紼嬶紝GUI錛屽鍣ㄧ被,浠ュ強嫻忚鐩綍鐨凙PI絳夌瓑銆?/p>
銆銆(4) Chilkat C++ Libraries
銆銆鍙傝冪綉绔欙細http://www.chilkatsoft.com/cpp_libraries.asp
銆銆榪欐槸鎻愪緵zip錛宔-mail錛岀紪鐮侊紝S/MIME錛孹ML絳夋柟闈㈢殑搴撱?/p>
銆銆(5) C++ Portable Types Library (PTypes)
銆銆鍙傝冪綉绔欙細http://www.melikyan.com/ptypes/
銆銆榪欐槸STL鐨勬瘮杈冪畝鍗曠殑鏇夸唬鍝侊紝浠ュ強鍙Щ妞嶇殑澶氱嚎紼嬪拰緗戠粶搴撱?/p>
銆銆(6) LFC
銆銆鍙傝冪綉绔欙細http://lfc.sourceforge.net/
銆銆鍝︼紝榪欏張鏄竴涓皾璇曟彁渚涗竴鍒囩殑C++搴?/p>
銆銆5.12 鍏朵粬搴?/p>
銆銆(1) Loki
銆銆鍙傝冪綉绔欙細http://www.moderncppdesign.com/
銆銆鍝︼紝浣犲彲鑳芥姳鎬ㄦ垜鏃╄鍜孊oost涓璧蜂粙緇嶅畠錛屼竴涓疄楠屾ц川鐨勫簱銆備綔鑰呭湪loki涓妸C++妯℃澘鐨勫姛鑳藉彂鎸ュ埌浜嗘瀬鑷淬傚茍涓斿皾璇曟妸綾諱技璁捐妯″紡榪欐牱鎬濇兂灞傞潰鐨勪笢瑗塊氳繃搴撴潵鎻愪緵銆傚悓鏃惰繕鎻愪緵浜嗘櫤鑳芥寚閽堣繖鏍鋒瘮杈冨疄鐢ㄧ殑鍔熻兘銆?/p>
銆銆(2) ATL
銆銆ATL(Active Template Library)
銆銆鏄竴緇勫皬宸с侀珮鏁堛佺伒媧葷殑綾伙紝榪欎簺綾諱負鍒涘緩鍙簰鎿嶄綔鐨凜OM緇勪歡鎻愪緵浜嗗熀鏈殑璁炬柦銆?/p>
銆銆(3) FC++: The Functional C++ Library
銆銆榪欎釜搴撴彁渚涗簡涓浜涘嚱鏁板紡璇█涓墠鏈夌殑瑕佺礌銆傚睘浜庣敤搴撴潵鎵╁厖璇█鐨勪竴涓唬琛ㄤ綔銆傚鏋滄兂瑕佸湪OOP涔嬪瀵繪壘鍙︿竴鍒嗙殑涔愯叮錛屽彲浠ュ幓鐪嬬湅鍑芥暟寮忕▼搴忚璁$殑涓栫晫銆傚ぇ甯圥eter Norvig鍦?鈥淭each Yourself rogramming in Ten Years鈥濅竴鏂囦腑灝卞皢鍑芥暟寮忚璦鍒椾負鑷沖皯搴斿綋瀛︿範鐨?綾葷紪紼嬭璦涔嬩竴銆?/p>
銆銆(4) FACT!
銆銆鍙傝冪綉绔欙細http://www.kfa-juelich.de/zam/FACT/start/index.html
銆銆鍙﹀涓涓疄鐜板嚱鏁板紡璇█鐗規х殑搴?/p>
銆銆(5) Crypto++
銆銆鎻愪緵澶勭悊瀵嗙爜錛屾秷鎭獙璇侊紝鍗曞悜hash錛屽叕鍖欏姞瀵嗙郴緇熺瓑鍔熻兘鐨勫厤璐瑰簱銆?/p>
銆銆榪樻湁寰堝闈炲父嬋鍔ㄤ漢蹇冩垨鑰呮槸鏋佸叾瀹炵敤鐨凜++搴擄紝闄愪簬鎴戜滑鐨勬按騫充互鍙婃枃绔犵殑綃囧箙涓嶈兘鍖呮嫭榪涙潵銆傚湪瀵逛簬榪欎簺宸茬粡鍖呭惈榪戞潵鐨勫簱鐨勪粙緇嶄腑錛岀敱浜庡茍涓嶆槸姣忎竴涓垜浠兘浣跨敤榪囷紝鎵浠ラ毦鍏嶆湁鍋忛涔嬪錛岃璇昏呰璋呫?/p>
--------------------------------------------------------------------------------
銆銆6錛屼功綾?/p>
銆銆浠ュ墠鐔婅妭鍏堢敓鏇炬挵鏂囪瘎璁虹浉瀵逛簬Java紼嬪簭璁捐璇█錛孋++鐨勫ソ涔﹀濡傜墰姣涖傝崳鑰鍏堢敓鍦ㄣ婄▼搴忓憳銆嬫潅蹇椾笂鎾版枃銆奀++紼嬪簭璁捐涔嬪洓涔︿簲緇忋嬩篃灝嗘湰棰嗗煙鍐呭嚑涔庢墍鏈夌殑緇忓吀涔︾睄浣滀簡鍏ㄩ潰鐨勪粙緇?浠諱綍鍏充簬涔︾殑璇勮姝ゆ椂鐪嬫潵渚挎槸寰堝浣欑殑浜嗐備釜浜烘祬瑙侊紝闄ら潪浣犳墦綆椾互C++浣滀負鍞竴鍏磋叮鎴栬呯敓瀛樹箣鏈紝涓鑸鑰呯‘瀹炴病鏈夎凍澶熺殑鏃墮棿鍜屽繀瑕佸皢20浣欐湰涔︾睄鍏ㄩ儴闃呰銆傛洿鏈夊弬鑰冧環鍊肩殑鏄崳鑰鍏堢敓鐨勫彟涓綃囨枃绔狅細銆婅嚦灝戝簲璇ラ槄
璇葷殑涔濇湰C++钁椾綔銆嬶紝鍙互浠庝笅闈㈢殑鍦板潃嫻忚鍒版鏂囷細
銆銆http://www.royaloo.com/articles/articles_2003/9CppBooks.htm
銆銆涓嬮潰鍑犳湰涔﹀浜庤蛋鍦–++鍒濆涔嬭礬涓婄殑璇昏呮槸鎴戜滑鏈鎰挎剰鎺ㄨ崘緇欏ぇ瀹剁殑錛?/p>
銆銆(1) 銆奀++ Primer銆?/p>
銆銆鍝︼紝涔熻浣犱細鎶辨ㄦ垜浠負浠涔堜笉鍏堜粙緇峊CPL,浣嗗浜庤蛋鍦ㄥ涔犱箣璺笂鐨勫叆闂ㄨ咃紝鏈功鍐呭鏇翠負鍏ㄩ潰錛屾洿涓鴻緇嗘槗鎳傦紝鎴戜滑縐板畠涓衡淐++鐨勮秴綰у疂鍏糕濆茍涓嶈繃鍒嗐傞厤鏈変竴鏈笉閿欑殑涔犻瑙g瓟銆奀++ Primer Answer Book銆嬪彲浠ヨ緟鍔╀綘鐨勫涔犱箣璺?/p>
銆銆(2) 銆奅ssential C++銆?/p>
銆銆濡傛灉璇淬奀++ Primer銆嬫槸C++棰嗗煙鐨勮秴綰у疂鍏革紝閭d箞姝や功浣滀負鎺屾彙C++鐨勫ぇ灞瑙傚綋涔嬫棤鎰с傛濡傘?NET澶у眬瑙傘嬩竴涔﹁兘澶熻璇昏呭叏鎻?NET錛屾湰涔﹁榪頒簡C++涓渶鏍稿績鐨勫叏閮ㄤ富棰樸備功铏戒笉鍘氾紝鍐呭綺劇偧錛屼笉澶變負銆奀++ Primer銆嬭鑰呰尪浣欓キ鍚庣殑涓婚鍥為【涔嬩綔銆?/p>
銆銆(3) 銆奣he C++ Programming Language銆?/p>
銆銆Bjarne涓轟綘甯︽潵鐨凜++鏁欑▼錛岀湡姝h兘澶熷憡璇変綘鎬庝箞鐢ㄦ墠鍙湡姝g殑C++鐨勫敮涓涓鏈功銆傝櫧鐒跺鍚屸滄煇鏌愮▼搴忚璁¤璦鈥濊繖鏍風殑涔︾睄浼氱粰澶у涓涓唴瀹瑰叏鎻斤紝鍏ラ棬鍒扮簿閫氱殑鎰熻錛屼絾鏈功紜疄涓嶅お閫傚悎鍒濆鑰呴槄璇匯傚鏋滀綘鑷涓烘槸涓鍚嶅緢鏈夌粡楠岀殑C++紼嬪簭鍛橈紝閭h嚦灝戜篃瑕佸弽澶嶅拃鍤糂jarne鍏堢敓鎵寮鴻皟鐨勮嫢騫插唴瀹廣?/p>
銆銆(4) 銆奅ffective C++銆嬶紝銆奙ore Effective C++銆?/p>
銆銆鏄殑錛屾濡備竴浜汣++鐖卞ソ鑰呯粡甯鎬互璇昏繃涓庢病鏈夎榪囦笂榪頒袱鏈綔鍝佹潵鍖哄垎浣犳槸鍚︽槸C++楂樻墜銆傛垜浠篃鏋佸姏鎺ㄥ磭榪欎袱鏈憲浣溿傚湪鍚勭浠嬬粛C++涓撳緇忛獙鐨勪功綾嶉噷闈紝榪欎袱鏈槸鏈璐磋繎璇█鏈川錛岀湅鍚庢渶鑳藉鏈夎劚鑳庢崲楠ㄦ劅瑙夌殑涔︼紝璇繪涔︿綘闇姣忔棩涓夌渷姹濊韓銆?/p>
銆銆鎶鏈功綾嶄粊鑰呰浠侊紝榪囧鐨勮瘎璁哄弽鏃犲お澶氭剰涔夛紝鐢辮鑰呭枩濂介夋嫨鏈閫傚悎鑷繁鐨勪功鏂逛負涓婄瓥銆?/p>
--------------------------------------------------------------------------------
銆銆7錛岃祫婧愮綉绔?/p>
銆銆姝e鎴戜滑鍙互閫氳繃璁$畻鏈哄巻鍙蹭笂鐨勯噸瑕佷漢鐗╀簡瑙h綆楁満鍙茬殑鍙戝睍錛孋++鐩稿叧浜虹墿鐨勭綉绔欎篃鍙互浣挎垜浠緱鍒版渶鏈変環鍊肩殑鍙傝冧笌鍊熼壌錛屼笅闈㈢殑浜虹墿鎴戜滑璁や負娌℃湁浠嬬粛鐨勫繀瑕侊紝鍙洜涓嬮潰鐨勪漢鐗╁湪C++棰嗗煙鐨勫湴浣嶄紬鎵鍛ㄧ煡錛屾垜浠彧灝嗙浉鍏崇殑璧勬簮榪涜緗楀垪浠ヤ緵璇昏呭涔狅紝浠栦滑鏈夌殑宸ヤ綔浜庤礉灝斿疄楠屽錛屾湁鐨勫伐浣滀簬鐭ュ悕緙栬瘧鍣ㄥ巶鍟嗭紝鏈夌殑鍦ㄤ笉鏂帹榪涜璦鐨勬爣鍑嗗寲錛屾湁鐨勪負璇昏呮挵鍐欎簡澶氶儴鍗冨彜濂囦綔鈥︹?br />銆銆(1) Bjarne Stroustrup
銆銆http://www.research.att.com/~bs/
銆銆(2) Stanley B. Lippman
銆銆http://blogs.msdn.com/slippman/
銆銆涓枃鐗?http://www.zengyihome.net/slippman/index.htm
銆銆(3) Scott Meyers
銆銆http://www.aristeia.com/
銆銆(4) David Musser
銆銆http://www.cs.rpi.edu/~musser/
銆銆(5) Bruce Eckel
銆銆http://www.bruceeckel.com/
銆銆(6) Nicolai M. Josuttis
銆銆http://www.josuttis.com/
銆銆(7) Herb Sutter
銆銆http://www.gotw.ca/
銆銆(8) Andrei Alexandrescu
銆銆http://www.coderncppdesign.com/
銆銆(9) 渚嵎鍏堢敓
銆銆http://www.jjhou.com/
銆銆(10) 瀛熷博鍏堢敓
銆銆鍏堢敓綣佸繖浜庡伐浣滐紝鐥磋糠浜庢妧鏈紝鏆傛棤涓漢涓婚〉錛屽叧浜庡厛鐢熺殑浣滃搧鍙互閫氳繃CSDN鐨勪笓鏍忓拰渚厛鐢熺殑涓婚〉璁塊棶鍒般?/p>
銆銆(11) 鑽h鍏堢敓
銆銆http://www.royaloo.com/
銆銆(12) 娼樼埍姘戝厛鐢?br />銆銆http://www.icst.pku.edu.cn/panaimin/pam_homepage.htm
銆銆闄や簡涓婅堪澶у笀鐨勪富欏靛錛屼互涓嬬殑緇煎悎綾籆++瀛︿範鍙傝冪珯鐐規槸鎴戜滑闈炲父鎰挎剰鍚戝ぇ瀹舵帹鑽愮殑錛?/p>
銆銆(1) CodeProject
銆銆http://www.codeproject.com/
銆銆(2) CodeGuru
銆銆http://www.codeguru.com/
銆銆(3) Dr. Dobb's Journal
銆銆http://www.ddj.com/
銆銆(4) C/C++ Users Journal
銆銆http://www.cuj.com/
銆銆(5) C緇磋鐐?br />銆銆http://www.c-view.org/
銆銆(6) allaboutprogram
銆銆http://www.allaboutprogram.com/
銆銆鍏朵粬璧勬枡
銆銆(1) ISO IEC JTC1/SC22/WG21 - C++錛氭爣鍑咰++鐨勬潈濞佸弬鑰?br />銆銆http://anubis.dkuug.dk/jtc1/sc22/wg21/
銆銆(2) C++ FAQ LITE 鈥?Frequently Asked Questions: 鏈涓哄叏闈㈢殑C++FAQ
銆銆http://www.sunistudio.com/cppfaq/index.html
銆銆C/C++ 鏂伴椈緇勶細
銆銆浣犱笉濡ㄥ皾璇曚粠榪欓噷鎻愰棶鍜屽洖絳旈棶棰橈紝寰堝涓嶉敊鐨凲&A璧勬簮......
銆銆(1) .alt.comp.lang.learn.c-c++
銆銆榪欎釜綆鍗曚簺錛屽鏋滀綘鍜屾垜涓鏍鋒槸涓彍楦?/p>
銆銆(2) .comp.lang.c++.moderated
聽 鍡紝榪欎釜鏄劇劧姘村鉤楂樹竴浜?/p>
銆銆(3) .comp.std.c++
銆銆濡傛灉浣犻渶瑕佽璁烘爣鍑咰++鐩稿叧璇濋鐨勮瘽
--------------------------------------------------------------------------------
銆銆8錛屼笉寰椾笉鍐欑殑緇撴潫璇?/p>
銆銆緇撴潫鐨勬椂鍊欎篃鏄葷粨鐜扮姸錛屽睍鏈涙湭鏉ョ殑鏃跺欍傝櫧鐒禖++浠庤劚鑳庝簬C寮濮嬶紝涓璺壈闅懼潕鍧風殑璧拌繃鏉ワ紝浣嗘槸鏃犺濡備綍C++宸茬粡鍙栧緱浜嗗伐涓氬熀紜鐨勫湴浣嶃傛枃绔犲垪涓劇殑澶ч噺鐩稿叧璧勬簮灝辨槸鏈濂界殑璇佹槑錛岃屼笟鐣岀殑澶ч噺鐢–++鍐欐垚鐨勪駭鍝佷唬鐮佷互鍙婂ぇ閲忕殑C++鑱屼笟宸ョ▼甯堝垯鏄渶鐩存帴鐨勮瘉鏄庛傚悓鏃訛紝鎴戜滑鍙互鐪嬪埌鍚勪釜楂樻牎鐨勮綆楁満涓撲笟閮藉紑璁炬湁C++榪欓棬璇劇▼錛岀綉緇滀笂瀵逛簬C++鐨勫涔犺璁轟篃浠庢潵閮芥病鏈夊仠榪囥備絾鏄紝鍦↗ava鍜?NET涓ゅぇ浼佷笟寮鍙戝鉤鍙扮殑鍥存敾涓嬶紝緇欎漢鐨勬劅瑙夋槸C++瓚婃潵瓚娾滀笉琛屸濅簡銆?/p>
銆銆C++鍦ㄩ潰鍚戜紒涓氱殑杞歡寮鍙戜腑錛屽湪寮鍙戜究鎹鋒х瓑鏂歸潰鐨勭‘瑕佹瘮Java鍜孋#宸緢澶氾紝鍏朵腑涓涓棶棰樻槸C++璇█鏈韓姣旇緝澶嶆潅錛屽涔犳洸綰挎瘮杈冮櫋宄紝鍙﹀涓涓棶棰樻槸C++鏍囧噯鍖栫殑鏃墮棿澶暱錛屼撫澶變簡寰堝鐨勫.澶ф満浼氾紝鑰楄垂浜嗗緢澶氱簿鍔涘湪鍘傚晢鐨勪箣闂寸殑鏂椾簤涓婏紝鑰孋++鐨勬爣鍑嗗簱紱諱竴涓畬鍠勭殑紼嬪簭寮鍙戞鏋惰繕緙哄皯澶澶鐨勫唴瀹癸紝鍚勪釜絎笁鏂圭殑綾誨簱鍜屾鏋跺張鍦ㄤ竴鑷存у拰瀹屾暣鎬т笂娌℃硶鍜岄殢騫沖彴鎻愪緵鐨勬鏋剁浉鎻愬茍璁恒傞毦閬揅++鐪熺殑瑕侀鍑哄巻鍙茶垶鍙頒簡錛?/p>
銆銆浠嶤++鐩墠鐨勬椿璺冪▼搴︼紝浠ュ強搴旂敤鐜扮姸鏉ヨ鏄畬鍏ㄨ兘澶熻偗瀹欳++浠嶇劧鏄蔣浠跺伐涓氱殑鍩虹錛屼篃涓嶄細閫鍑哄巻鍙茶垶鍙扮殑銆傚彟澶栦粠Boost錛孡oki榪欎簺搴撲腑鎴戜滑涔熻兘澶熺湅鍒癈++鐨勫彂灞曢潪甯告椿璺冿紝瀵逛簬鏂版妧鏈柊鎬濈淮闈炲父嬋榪涳紝C++浠嶇劧騫挎硾鍙楀埌鍏蟲敞銆備粠ACE鍦ㄩ珮鎬ц兘閫氫俊棰嗗煙鐨勫簲鐢紝浠ュ強MTL榪欐牱鐨勫簱鍦ㄦ暟鍊艱綆楅鍩熺殑鍑鴻壊琛ㄧ幇錛屾垜浠彲浠ョ湅鍒癈++鍦ㄩ珮鎬ц兘搴旂敤鍦哄悎涓嬬殑涓嶅彲鏇夸唬鐨勪綔鐢紝鑰屽祵鍏ュ紡緋葷粺榪欐牱鐨勫唴瀛樺彈闄愬紑鍙戝鉤鍙?br />錛屾瘮濡係ymbian OS涓婏紝C++宸茬粡鍙戞尌鐫騫朵笖灝嗗彂鎸ユ洿澶х殑浣滅敤銆傚彲浠ラ瑙佺殑鏄互鍚庣殑杞歡鏃犺涓婂眰鐨勫簲鐢ㄦ庝箞鍙橈紝瀹冪殑搴曞眰鏍稿績閮戒細鏄敱C/C++榪欐牱鐨勭郴緇熺駭杞歡緙栧啓鐨勶紝姣斿Java铏氭嫙鏈猴紝.NET Framwork銆傚洜涓哄彧鏈夎繖鏍風殑緋葷粺綰ц蔣浠舵墠鑳藉畬鍏ㄥ交搴曠殑鍙戞尌鏈哄櫒鐨勫姛鑳姐?/p>
銆銆闇瑕佺湅鍒扮殑鏄袱涓秼鍔匡紝涓涓秼鍔挎槸C++鍙樺緱鏇村姞澶嶆潅錛屾洿鍔犲闄㈡淳錛岄氳繃妯℃澘絳夋湁娼滃姏鐨勮娉曞洜绱犳瀯閫犺秺鏉ヨ秺綺懼閥鐨勫簱鎴愪負浜嗙幇浠++鐨勭儹鐐癸紝铏界劧鍦ㄥ埄鐢ㄥ簱瀹炵幇鏂扮殑緙栫▼鑼冨紡錛屼箖鑷寵璁℃ā寮忕瓑鏂歸潰寰堟湁寮鍒涙剰涔夛紝涔熺‘瀹炰駭鐢熶簡涓浜涜兘澶熶究鎹峰紑鍙戠殑宸ュ叿錛屼絾鏄洿澶氱殑鏄妸C++鍙樺緱鏇村姞寮哄ぇ錛屾洿鍔犲鏉傦紝涔熸洿鍔犻毦鎳傦紝浼間箮涔熸洿鍔犲闄㈡淳錛屼笉寰椾笉璇村畠姝e湪鍚戣竟緙樺寲閬撹礬鍙戝睍銆傚彟涓涓秼鍔挎槸C++鍦ㄤ富嫻佺殑浼佷笟搴旂敤寮
鍙戜腑宸茬粡閫愭笎閫鍑轟簡錛孍RP榪欐牱鐨勪紒涓氳蔣浠跺紑鍙戜腑鍩烘湰涓婁笉浼氳冭檻C++錛岄櫎闈為渶瑕佽冭檻鎬ц兘鎴栬呭拰閬楃暀浠g爜鐨勯泦鎴愯繖浜涘洜绱犮侰++閫瀹堝埌緋葷粺綰у埆璇█錛屾垚涓鴻蔣浠跺伐涓氱殑鍩虹鏄ぇ鍔挎墍瓚嬨傜劧鑰屽弽鎬濅竴涓嬶紝鐪熺殑鏄瀹堜箞錛熻嚜浠嶴TL鍑虹幇錛屾棤鏁扮殑浜洪璧蜂簯娑岀殑寮濮嬫敮鎸丆++,浠栦滑鐙傚懠鈥滄垜鐪嬪埌娣卞娑堝け浜嗭紝鐩爣杞歡宸ョ▼鐨勫嚭鐜般傛垜鐪嬪埌浜嗗彲緇存姢鐨勪唬鐮併傗濇槸鐨勶紝STL鍦ㄥ彲緇存姢鎬т笅鍋氬緱濡傛鍑鴻壊銆備絾鏄張鎬庢牱鍛紵STL涓篊++閾哄鉤浜嗙幇浠h蔣浠跺伐紼嬬殑閬撹礬錛岃屽湪涓婂眰搴旂敤紼嬪簭杞歡寮鍙戦鍩熻繖鍧楀満鍦版棭涓嶅崟鐙睘浜嶤++,寰堝紼嬪簭璁捐璇█閮藉仛寰楀緢鍑鴻壊錛岀柉鐙傜殑鏀寔鑰呬細姣笉鐘硅鮑鍦拌鎴戜滑搴斿綋鏀寔C++,鍥犱負瀹冩槸涓栫晫涓婃渶媯掔殑璇█銆傝屽潶鐜囧湴璇達紝浣犵殑鑵版潌鐪熺殑閭d箞紜箞錛熶篃璁稿彧鏄湪閫冮伩涓浜涗簨瀹炪侰++鏄紭縐鐨勶紝榪欎笉鍙惁璁わ紝STL鐨勫嚭鐜拌C++涓搴﹁蛋涓婁簡鏈杈夌厡鐨勬椂鍒伙紝鐒惰岀幇鍦ㄧ湅鏉モ︹︽垜鐨勪竴浣嶆仼甯堟浘璦錛氱湡姝h兘澶熷皢STL搴旂敤寰楁穻婕撳敖鑷寸殑浜哄緢
淇濆畧鍦拌鍥藉唴涔熶笉瓚呰繃200浜猴紝鎴栬涓嶅姞鍏TL鑳藉浣緾++鍚戠潃瀹冨簲褰撳彂灞曠殑鏂瑰悜鍙戝睍鐨勬洿濂斤紝鑰岀幇鍦ㄧ湅鏉ワ紝C++涔熷簲褰撳洖棣栧埌鐪熸灞炰簬浠栫殑閭d竴鐗囧湥鍦頒笂鈥︹?/p>
聽聽聽 By default, the COM Server code that the WTL AppWizard adds does not have the _Module.RegisterServer function set to TRUE by default. As a result, the type library information never showed up in the registry. A message in the ATL Archives relayed the answer to this problem.
聽聽聽 After trying to use extended combo boxes within a WTL app and not getting them to load, I knew I must be doing something wrong. I was initializing them with ::InitCommonControlsEx() in OnInitDialog(), which was a little too late. I moved them to DllMain, and that solved the problem. (The Microsoft ATL mailing list archives saved the day ...)
聽聽聽 I was trying to modify a WTL frame window by using ModifyStyle in OnCreate(). WTL doesn't like this very well. Instead I discovered that I got the results I was looking for by modifying CFrameWindowImpl to take a customized version of CWinTraits by adding it to the template definition. By the way, this also works for CWindowImpl, which is where I found this trick in the MSDN docs and ATL Internals. Also, this link shows another tricky portion of the whole process.
聽聽聽 Steps to use CDialogResize (from WTL 3.1):
聽聽聽 1) #include <atlframe.h> in your view/dialog class
聽聽聽 2) derive your view/dialog from CDialogResize:
聽聽聽聽聽聽聽 class CMyClass: public CDialogImpl<CMyClass>, ....
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 public CDialogResize<CMyClass>
聽聽聽 3) Add a DLGRESIZE_MAP to your view as follows:
聽聽聽聽聽聽聽聽 BEGIN_DLGRESIZE_MAP(CMyClass)
聽聽聽聽聽聽聽聽聽聽聽聽聽 DLGRESIZE_CONTROL(IDOK, DLSZ_MOVE_X | DLSZ_SIZE_Y)
聽聽聽聽聽聽聽 END_DLGRESIZE_MAP()
聽聽聽聽聽聽聽 The first parameter in the DLGRESIZE_CONTROL macro is the resource ID of your control. The second parameter(s) is the way that you want that control to be resized; valid values are DLSZ_MOVE_X, DLSZ_MOVE_Y, DLSZ_SIZE_X, DLSZ_SIZE_Y. (Note that you can OR these together with a |). You can also resize controls as a group by enclosing a number of DLGRESIZE_CONTROL macros with BEGIN_DLGRESIZE_GROUP() and END_DLGRESIZE_GROUP(). More on grouping in the next tip.
聽聽聽 4) Chain your message map to CDialogResize, i.e.
聽聽聽聽聽聽聽聽聽聽聽 BEGIN_MSG_MAP(CMyClass)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ....
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 CHAIN_MSG_MAP(CDialogResize<CMyClass>)
聽聽聽聽聽聽聽聽聽聽聽 END_MSG_MAP()
聽聽聽 5) Initialize the resizing for your view with DlgResize_Init(false, true, WS_CLIPCHILDREN) in OnInitDialog. Normally (for standard dialogs) you would just use DlgResize_Init() and accept the default parameters, but for a view you have to supply the extra settings since the view doesn't need a gripper or a frame like a dialog would.
聽 Some things I've noticed about grouping controls with CDialogResize:
聽聽 1) You can group controls in one direction and leave them ungrouped in another direction to achieve good effects.
聽聽聽聽聽聽聽 For instance, if you had Save, Print and Close buttons running along the bottom of your dialog, centered and spaced evenly apart, you'd probably want to do this grouping:
聽聽聽聽聽聽 BEGIN_DLGRESIZE_MAP(CMyClass)
聽聽聽聽聽聽聽聽聽聽聽 BEGIN_DLGRESIZE_GROUP()
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 DLGRESIZE_CONTROL(IDC_BTN_SAVE, DLSZ_MOVE_X )
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 DLGRESIZE_CONTROL(IDC_BTN_PRINT, DLSZ_MOVE_X )
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 DLGRESIZE_CONTROL(IDC_BTN_CLOSE, DLSZ_MOVE_X)
聽聽聽聽聽聽聽聽聽聽聽 END_DLGRESIZE_GROUP()
聽聽聽聽聽聽聽聽聽聽聽 DLGRESIZE_CONTROL(IDC_BTN_SAVE, DLSZ_MOVE_Y)
聽聽聽聽聽聽聽聽聽聽聽 DLGRESIZE_CONTROL(IDC_BTN_PRINT, DLSZ_MOVE_Y)
聽聽聽聽聽聽聽聽聽聽聽 DLGRESIZE_CONTROL(IDC_BTN_CLOSE, DLSZ_MOVE_Y)
聽聽聽聽聽聽 END_DLGRESIZE_MAP()
聽聽聽聽聽聽 This would keep all of them centered and spaced evenly as you moved them, while also moving them up and down independently.
聽聽聽 2) As soon as you noticed this little trick, however, you might start to take notice that your buttons don't exactly line up with the other controls on screen. You'd see this as the dialog was sized larger and larger. What's happening is that the leftmost button in the resource (this doesn't mean the top one in the DLGRESIZE_GROUP -- it's unrelated) is acting as an anchor for all the other buttons in the group. So when you resize the dialog, the leftmost button isn't moving ... it's just staying in place.
聽聽聽 There may be better ways to solve this problem, but what I did is insert a new invisible button on the resource in the leftmost position to act as the anchor. I then included the button in the DLGRESIZE_GROUP with a DLSZ_MOVE_X command as well so it would make all the other three buttons move together correctly. Like I said -- it works. If you stumble on something better
聽聽聽聽 WTL 鏈緇堟潵浜?/span> , 鑰屼笖 鎻愪緵浜嗘垜鎵甯屾湜鐨勫姛鑳?/span> . 鎴戝湪 WTL Bytesize (璇戞枃)鐨勬枃绔犲垪鍑?/span> WTL 涓昏鐗瑰緛 . 鍦ㄦ湰鏂囦腑 , 鎴戝皢鎻忚堪涓涓?/span> WTL 鐨勪綋緋葷粨鏋?/span> , 鍚屾椂鎴戜細緇欏嚭涓浜涚畝鍗曠殑渚嬪瓙鏉ユ紨紺哄浣曚嬌鐢ㄥ畠鐨勯偅浜涚壒寰?/span> . 甯屾湜鑳藉瀵規偍鏈?span lang="zh-cn">鎵甯姪 . 聽
WTL 搴旂敤紼嬪簭鐨勭被鍨?/font>
聽聽聽聽 WTL 鏈夊ソ鍑犵搴旂敤紼嬪簭綾誨瀷 , 渚涙偍鍦?/span> AppWizard 閫夊彇 .
聽聽聽 涓嬭〃瀵硅繖浜涘簲鐢ㄧ▼搴忚繘琛屼簡鎻忚堪
.
榪欑寮規ф瀯鎴愪簡
WTL
浣撶郴緇撴瀯鐨勪竴閮ㄥ垎
.
| 搴旂敤紼嬪簭綾誨瀷 | 鎻忚堪 |
| SDI Application | 鍗曟枃鏈晫闈?/span> 鈥? 鍙湁涓涓獥鍙?/span> |
| Multiple Threads SDI | 鍗曚釜榪涚▼鎷ユ湁涓涓垨澶氫釜紿楀彛 |
| MDI Application | 澶氭枃鏈晫闈?/span> 鈥? 鍦ㄦ鏋跺唴 , 鎮ㄥ彲浠ユ湁闆朵釜鎴栧涓瓙紿楀彛 |
| Dialog Based | 鍩轟簬瀵硅瘽妗嗘ā鐗?/span> |
聽聽聽 浣犲彲鑳借繕鏄嬈″惉璇村綰跨▼SDI搴旂敤紼嬪簭,浣嗘槸涓嶇敤鎷呭績,瀹冪殑姒傚康寰堝鏄撶悊瑙?涓涓綰跨▼SDI紼嬪簭鍚姩鍚庡畠浼氭湁涓涓獥鍙? 紿楀彛鏄劇ず浜嗕竴涓枃妗? 褰撲綘鎯寵紼嬪簭瑕佸啀鍒涘緩涓涓枃妗f椂,闂灝卞嚭鐜頒簡--SDI紼嬪簭鍙兘鏄劇ず涓涓枃妗?涓轟簡瑙e喅榪欎釜闂,澶氱嚎紼婼DI鍒涘緩浜嗗彟涓涓猄DI紿楀彛.鐪嬭搗鏉ユ槸涓涓柊鐨勫疄渚嬪湪榪愯,瀹為檯涓婂畠涓嶈繃鏄師鏉ョ殑榪涚▼鍒涘緩浜嗕竴涓柊鐨勭獥鍙?騫舵妸瀹冧緷闄勫埌榪涚▼鐨勪竴涓柊綰跨▼. IE鐨勬柊寤虹獥鍙e氨鏄繖鏍峰仛鐨? 聽
聽聽聽 闄や簡澶氱嚎紼?span lang="EN-US">SDI,鎵鏈夎繖浜涘簲鐢ㄧ▼搴忛兘鍙互浣滀負COM鏈嶅姟鍣? 騫朵笖搴旂敤紼嬪簭鍚戝(AppWizard)涓烘鎻愪緵浜嗕竴涓夐」.鍙﹀搴旂敤紼嬪簭鍚戝榪樺彲浠ヨ浣犳寚瀹氳紼嬪簭鏄惁涓繪寔ActiveX鎺т歡.浠や漢璐硅В鐨勬槸,涓嶅悓鐨勭▼搴忕被鍨?閫夊彇"Host ActiveX Controls"鐨勫湴鏂逛笉鍚?闄ゅ璇濇搴旂敤紼嬪簭澶栫殑鍏朵粬綾誨瀷鍦ㄧ涓欏典笂閫夊彇,鑰屽璇濇綾誨瀷鍗存斁鍒扮浜岄〉. 聽
聽聽聽 絎簩欏電殑鍏朵粬閫夐」,瀵瑰璇濇紼嬪簭浠ュ鐨勭被鍨嬮兘鏄彲鐢ㄧ殑.瀹冧滑璁╀綘鎸囧畾紼嬪簭鏄惁闇瑕佸伐鍏鋒潯(toolbar),鐘舵佹潯(status bar)鍜岃紿楀彛(View Window).
聽聽聽 濡傛灉閫夊彇浜?Toolbar"閫夐」,浣犲彲浠ラ氳繃"Rebar"閫夋嫨鏄惁灝嗗伐鍏鋒潯鏀懼叆IE Rebar鎺т歡涓? 濡傛灉浣犻夊彇浜哛ebar, 浣犲氨鍙互閫氳繃妗嗘灦紿楀彛(frame window)鐨勬垚鍛榤_hWndToolBar(鍚庤竟浼氭湁璇︾粏鐨勬弿榪?鏉ヨ闂畠.浣犲彲浠ユ寜鐓т綘鐨勬剰鎰?鍦ㄩ噷杈瑰姞鍏ュ叾浠栫殑宸ュ叿鏉? 閫夊彇浜?Rebar"鍚? 浣犲彲浠ュ喅瀹氭槸鍚﹂夊彇"Command Bar".
Command bar寰堝儚CE鐨刢ommand bar鎺т歡.鍙槸WTL鏄敤涓涓被鏉ュ疄鐜?鑰屽湪CE, command bar鏄竴涓郴緇熺獥鍙g被(system window class). Command bar闈炲父鏈夌敤,瀹冭兘澶熸妸紿楀彛涔熷姞鍏ュ埌宸ュ叿鏉′腑鍘? 濡傛灉浣犻夊彇浜嗚繖涓夐」, 宸ュ叿鏉″拰鑿滃崟閮藉皢琚綋鍋歵oolbar鏉ュ疄鐜?榪欎嬌鑿滃崟欏逛篃鍙互鏈夊叧鑱旂殑鍥炬爣,騫朵笖褰撲綘縐誨姩榧犳爣鍒頒竴涓彍鍗曢」涓婃椂,璇ヨ彍鍗曢」浼氳緗垚楂樹寒.浠嶰ffice 97浠ユ潵, Office杞歡鐨勮彍鍗曢兘鍏鋒湁涓婅堪鐗瑰緛.
聽
聽聽聽 絎簩欏佃繕鏈夋寚瀹氱▼搴忔槸鍚︿嬌鐢ㄨ鐨勯夐」(澶氬崐浣犳兂瑕佷嬌鐢?, 鍚屾椂浣犲彲浠ュ喅瀹氳繖浜涜濡備綍瀹炵幇. 涓嬭〃鍒楀嚭浜嗘墍鏈夊彲閫夌殑瑙? 聽
| 瑙?/span> | 鎻忚堪 |
| Generic Window | 涓涓畝鍗曠殑紿楀彛 . 姝ょ被紿楀彛鍏佽紼嬪簭鍛樼紪鍐?/span> WM_PAINT 娑堟伅鐨勫鐞嗗嚱鏁?/span> . 閫傜敤浜庨渶瑕佺洿鎺ヨ繘琛?/span> paint 鐨勬枃妗?/span> . |
| Form | 榪欑被瑙嗗叿鏈変竴涓璇濇妯$増 . 閫傜敤浜庡甫 ActiveX 鎺т歡鐨勭獥鍙?/span> . 搴旂敤紼嬪簭鏉ユ搷浣滆繖浜涙帶浠?/span> . |
| List Box | 榪欎釜瑙嗘槸涓?/span> list box. 瀹冩渶綆鍗曠殑褰㈠紡鎰忓懗鐫鍙互閫氳繃璋冪敤 AddString() 鏂規硶鏉ユ坊鍔犲瓧絎︿覆 . |
| Edit | 榪欎釜瑙嗘槸涓?/span> edit control. 鏈川涓?/span> , 瀹冩彁渚涗簡涓涓儚 Notepad 涓鏍風殑紼嬪簭 . |
| List View | 榪欎釜瑙嗘槸涓?/span> list view 閫氱敤鎺т歡 . 鐢ㄨ繖涓帶浠舵潵鏄劇ず鐩稿叧鐨勯」 ( 姣斿 , 鎺у埗闈㈡澘鏄竴涓?/span> Explorer 涓繪寔鐨?/span> List View, 鎵鏈夌殑欏歸兘鏄帶鍒墮潰鏉?/span> applet). |
| Tree View | 榪欎釜瑙嗘槸涓?/span> tree view 閫氱敤鎺т歡 . 榪欎釜閫傜敤浜庡叿鏈夊眰嬈″叧緋葷殑鏁版嵁 , 姣斿 , 鍙互鐢ㄥ畠鏉ユ樉紺烘暟鎹簱鐨?/span> schema. 欏跺眰鍒嗘敮涓鴻〃鍜屽瓨鍌ㄨ繃紼?/span> , 嬈$駭鐨勫垎鏀負琛ㄤ腑鐨勫瓧孌?/span> . |
| Rich Edit | 榪欎釜瑙嗘槸涓?/span> rich edit 鎺т歡 , 鍍?/span> WordPad. |
| HTML Page | 榪欎釜瑙嗕富鎸佷簡涓涓?/span> IE Web Browser 鎺т歡 . 瀹冩妸涓繪寔鐨勪竴涓?/span> web page 褰撴垚涓涓 . |
聽聽聽 鏈枃鐨勪緥瀛愰渶瑕佷竴涓璇濇妯$増
,
鍚屾椂榪橀渶瑕佽彍鍗?/span>
,
鍥犳
Form view
鏄釜鐞嗘兂鐨勯夋嫨
.
紼嬪簭綰跨▼
聽聽聽 璺烝TL涓鏍?WTL紼嬪簭涔熼渶瑕佷竴涓?font face="Courier New">_Module鍏ㄥ眬鍙橀噺鏉ヤ繚瀛樺叏灞鏁版嵁,鏂逛究搴旂敤綰т唬鐮佽闂?鍦╓TL涓?榪欎釜鍙橀噺鏄?font face="Courier New">CAppModule鎴?font face="Courier New">CServerAppModule鐨勫疄渚?鍚庤呭湪紼嬪簭鍚屾椂浣滀負涓涓狢OM鏈嶅姟鍣ㄦ椂鐢ㄥ埌.姣忎釜搴旂敤紼嬪簭鍏鋒湁涓涓垨鑰呭涓猆I綰跨▼.WTL浣跨敤涓ょ鏂瑰紡鏉ョ鐞嗚繖浜涚嚎紼?
聽聽聽 濡傛灉搴旂敤紼嬪簭鍙湁涓涓猆I綰跨▼(闄や簡澶氱嚎紼婼DI浠ュ,鍏朵粬紼嬪簭綾誨瀷榛樿鍙湁涓涓猆I綰跨▼),綰跨▼璋冪敤鍏ㄥ眬鍑芥暟run():
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
聽聽聽 CMessageLoop theLoop;
聽聽聽 _Module.AddMessageLoop(&theLoop);
聽聽聽 CMainFrame wndMain;
聽聽聽 if (wndMain.CreateEx() == NULL)
聽聽聽 {
聽聽聽聽聽聽聽 ATLTRACE(_T("Main window creation failed!\n"));
聽聽聽聽聽聽聽 return 0;
聽聽聽 }
聽聽聽 wndMain.ShowWindow(nCmdShow);
聽聽聽 int nRet = theLoop.Run();
聽聽聽 _Module.RemoveMessageLoop();
聽聽聽 return nRet;
}
聽聽聽 綰跨▼鐨勬秷鎭驚鐜寘鍚湪CMessageLoop鍐呴儴.鍑芥暟鍒涘緩浜嗕竴涓?b>CMessageLoop瀹炰緥, 鎶婂畠鏀懼叆鍏ㄥ眬鐨勬秷鎭驚鐜槧灝?message loop map)鏁扮粍. 浠ョ嚎紼婭D涓虹儲寮?綰跨▼涓繍琛岀殑鍏朵粬鐨勪唬鐮佸彲浠ヨ闂埌榪欎釜瀹炰緥. 娑堟伅寰幆瀵硅薄鍖呭惈浜唌essage filter鍜宨dle handler. 榪愯鍦ㄨ繖涓猆I綰跨▼鐨刄I鍏冧歡(UI element)鍙互鏈夊畠鑷繁鐨刬dle handler,鍦ㄧ嚎紼嬬殑娑堟伅闃熷垪涓虹┖鏃惰繍琛?font face="瀹嬩綋">銆?/font>璇戞敞:閫氳繃CMessageLoop::AddIdleHandler()鎶婅繖涓猆I鍏冧歡鍔犲叆鍒?b>CMessageLoop鐨刬dle handler 鏁扮粍涓?font face="瀹嬩綋">銆?/font>. CMessageLoop::Run()鍖呭惈浜哢I綰跨▼鐨勪富娑堟伅鏄犲皠(main message map).涓嬭竟鏄畠鐨勪吉浠g爜:
MSG m_msg;
int CMessageLoop::Run()
{
聽聽聽 for (;;)
聽聽聽 {
聽聽聽聽聽聽聽 while (!::PeekMessage(&m_msg, NULL, 0, 0, PM_NOREMOVE))
聽聽聽聽聽聽聽聽聽聽聽 DoIdleHandlers();
聽聽聽聽聽聽聽 bRet = ::GetMessage(&m_msg, NULL, 0, 0);
聽聽聽聽聽聽聽 if(bRet == -1)
聽聽聽聽聽聽聽聽聽聽聽 continue;
聽聽聽聽聽聽聽 else if(!bRet)
聽聽聽聽聽聽聽聽聽聽聽 break;
聽聽聽聽聽聽聽 if (!DoMessageFilters(&m_msg))
聽聽聽聽聽聽聽 {
聽聽聽聽聽聽聽聽聽聽聽 ::TranslateMessage(&m_msg);
聽聽聽聽聽聽聽聽聽聽聽 ::DispatchMessage(&m_msg);
聽聽聽聽聽聽聽 }
聽聽聽 }
聽聽聽 return (int)m_msg.wParam;
}
聽聽聽 鍙互鐪嬪埌,榪欎釜鍑芥暟鎺ㄥ姩鐫娑堟伅闃熷垪. 娌℃湁娑堟伅鏃? 榪愯娉ㄥ唽鍒扮嚎紼嬬殑idle hander. 濡傛灉鍦ㄩ槦鍒椾腑媯嫻嬪埌娑堟伅,鎶婂畠鍙栧嚭鏉?浼犵粰姣忎釜message filter. 濡傛灉娑堟伅娌℃湁琚繖浜涘嚱鏁板鐞?瀹冨皢鎸夌収閫氬父鐨勬柟寮?鍙戦佸埌鐩爣紿楀彛.
聽聽聽 濡傛灉紼嬪簭鏈夎秴榪囦竴涓殑UI綰跨▼,鍙互鐢╓TL鐨勭嚎紼嬬鐞嗗櫒,澶氱嚎紼婼DI灝辨槸榪欐牱鍋氱殑. 涓葷嚎紼嬩綔涓轟竴涓鐞嗚呯嚎紼?瀹冧細涓烘瘡涓柊紿楀彛鍒涘緩涓涓柊鐨?span lang="zh-cn">鏂?/span>綰跨▼. 涓昏嫻佺▼濡備笅:
int nRet = m_dwCount;
DWORD dwRet;
while(m_dwCount > 0)
{
聽聽聽 dwRet = ::MsgWaitForMultipleObjects(m_dwCount, m_arrThreadHandles,
聽聽聽聽聽聽聽 FALSE, INFINITE, QS_ALLINPUT);
聽聽聽 if(dwRet >= WAIT_OBJECT_0 && dwRet <= (WAIT_OBJECT_0 + m_dwCount - 1))
聽聽聽聽聽聽聽 RemoveThread(dwRet - WAIT_OBJECT_0);
聽聽聽 else if(dwRet == (WAIT_OBJECT_0 + m_dwCount))
聽聽聽 {
聽聽聽聽聽聽聽 ::GetMessage(&msg, NULL, 0, 0);
聽聽聽聽聽聽聽 if(msg.message == WM_USER)
聽聽聽聽聽聽聽聽聽聽聽 AddThread(_T(""), SW_SHOWNORMAL);
聽聽聽 }
}
閭d簺綰跨▼鍙ユ焺鏀懼湪涓涓暟緇勪腑. 綰跨▼閫氳繃AddThread()鍔犲叆鍒版暟緇?鍚屾椂鍚姩綰跨▼), RemoveThread()浠庢暟緇勭Щ璧? wait璇彞鍦ㄤ袱縐嶆儏鍐典笅浼氳鎵撴柇: 綰跨▼姝諱骸(灝嗙嚎紼嬩粠鏁扮粍涓Щ鍑? 鎴栫嚎紼嬫敹鍒頒簡WM_USER娑堟伅(涓涓嚎紼嬪湪涓涓柊綰跨▼閲屾柊寤轟簡涓涓獥鍙?. 綰跨▼綆$悊鑰呬負紼嬪簭涓殑涓涓被,鍥犳鍙互鍦ㄥ驚鐜腑鍔犲叆鑷繁鐨刴essage handler, 姣斿,褰撶▼搴忔湁涓嶆涓縐嶇獥鍙g被鍨嬫椂. 鍒涘緩涓涓柊鐨勭獥鍙i潪甯哥畝鍗?鍙渶鍦ㄤ換鎰忎竴涓獥鍙d腑璋冪敤:
::PostThreadMessage(_Module.m_dwMainThreadID, WM_USER, 0, 0L);
榪欎釜寰幆浼氫竴鐩磋繍琛屼笅鍘?鐩村埌鎵鏈夌殑UI綰跨▼閮藉叧闂簡. UI綰跨▼鍏鋒湁涓涓猼hread procedure,瀹冭窡鍗昒I綰跨▼鐨凴un()鏂規硶涓鏍?涓嶈繃,鐢變簬綰跨▼綆$悊鑰呬嬌鐢ㄤ簡MsgWaitForMultipleObjects(), 榪欐剰鍛寵呮渶澶氬彧鑳芥湁MAXIMUM_WAIT_OBJECTS-1涓猆I綰跨▼,榪欎篃鎰忓懗鐫鏈澶氬彧鑳藉垱寤?3涓獥鍙?
妗嗘灦
聽聽聽 WTL瀹為檯涓婃槸涓ょ被紿楀彛: 妗嗘灦紿楀彛鍜岃鍥劇獥鍙? 姝e鍚嶅瓧鎵鏆楃ず鐨勯偅鏍? 妗嗘灦紿楀彛涓虹獥鍙f彁渚涙爣棰樻爮(caption bar)鍜岃竟妗?浣犵殑浠g爜鐢ㄥ畠鏉ュ鐞嗗伐鍏鋒潯(tool bar)鍜岃彍鍗曢」鍛戒護.浣犵湅鍒扮殑紼嬪簭紿楀彛瀹為檯涓婃槸瑙嗗浘紿楀彛, 瑙嗗浘瑕嗙洊浜嗘鏋剁獥鍙g殑瀹㈡埛鍖?瀹㈡埛鍖烘槸鎸囨鏋剁獥鍙f病鏈夎璇稿鐘舵佹潯,宸ュ叿鏉′箣綾葷殑淇グ閮ㄤ歡鎵閬尅鐨勯儴鍒?
聽聽聽 綰跨▼浼氬垱寤轟富妗嗘灦紿楀彛鐨勪竴涓疄渚?鍒涘緩瑙嗗浘鐨勫伐浣滅敱涓繪鏋剁獥鍙g殑WM_CREATE娑堟伅澶勭悊鍑芥暟瀹屾垚. 瀵逛簬SDI紼嬪簭鏉ヨ,榪欎釜榪囩▼寰堢畝鍗? 鎶婅鍥劇被鐨勪竴涓疄渚嬩綔涓轟富妗嗘灦綾葷殑涓涓垚鍛?璋冪敤瑙嗗浘綾葷殑Create()鏂規硶鍗沖彲.MDI紼嬪簭紼嶅井鏈変簺涓嶅悓, MDI涓繪鏋剁獥鍙i氳繃CMDIFrameWindowImpl<>::CreateMDIClient()寤虹珛涓涓悕涓?b>MDICLIENT鐨勭獥鍙? 榪欎釜瀹㈡埛紿楀彛灝?font face="Courier New">CMDIChildWindowImpl<>紿楀彛褰撳仛瀹冪殑瀛愮獥鍙?瀛愮獥鍙f湁涓涓鍥?榪欎篃鍙嶆槧浜嗚繖涔堜竴涓簨瀹?MDI紼嬪簭鍙互鍏鋒湁闆朵釜鎴栬呭涓瓙紿楀彛,姣忎釜閮芥湁杈規鍜屾爣棰樻爮.
妗嗘灦紿楀彛鐨凮nCreate()寰堟湁鎰忔?璁╂垜鐪嬬湅:
LRESULT OnCreate(UINT, WPARAM, LPARAM, BOOL&)
{
聽聽聽 // create command bar window
聽聽聽 HWND hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault,
聽聽聽聽聽聽聽 NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);
聽聽聽 // attach menu
聽聽聽 m_CmdBar.AttachMenu(GetMenu());
聽聽聽 // load command bar images
聽聽聽 m_CmdBar.LoadImages(IDR_MAINFRAME);
聽聽聽 // remove old menu
聽聽聽 SetMenu(NULL);
聽聽聽 HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME,
聽聽聽聽聽聽聽 FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);
聽聽聽 CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);
聽聽聽 AddSimpleReBarBand(hWndCmdBar);
聽聽聽 AddSimpleReBarBand(hWndToolBar, NULL, TRUE);
聽聽聽 CreateSimpleStatusBar();
聽聽聽 m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL,
聽聽聽聽聽聽聽 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
聽聽聽聽聽聽聽 WS_EX_CLIENTEDGE);
聽聽聽 UIAddToolBar(hWndToolBar);
聽聽聽 UISetCheck(ID_VIEW_TOOLBAR, 1);
聽聽聽 UISetCheck(ID_VIEW_STATUS_BAR, 1);
聽聽聽 CMessageLoop* pLoop = _Module.GetMessageLoop();
聽聽聽 pLoop->AddMessageFilter(this);
聽聽聽 pLoop->AddIdleHandler(this);
聽聽聽 return 0;
}
聽聽聽 榪欐槸浠庝竴涓猄DI紼嬪簭鎷挎潵鐨勪竴孌典唬鐮?璇ョ▼搴忔湁涓涓熀浜巆ommand bar鐨勫伐鍏鋒潯鍜屼竴涓姸鎬佹潯. 鍑芥暟鐨勭涓琛屽垱寤轟簡涓涓猚ommand bar瀹炰緥,鐒跺悗瀵瑰畠榪涜鍒濆鍖?鍦ㄥ叾涓姞鍏ユ鏋剁獥鍙g殑鑿滃崟鍜屽伐鍏鋒潯浣嶅浘. 榪欐浠g爜鍏堝皢鑿滃崟鍙栧嚭,鎶婃墍鏈夌殑涓嬫媺鑿滃崟杞崲涓哄伐鍏鋒潯鎸夐挳,騫跺皢鑿滃崟淇濆瓨鍦ㄤ竴涓彉閲忎腑,浠ュ鍚庣敤. 緇欎漢鐨勬劅瑙夋槸鑿滃崟鏄敱宸ュ叿鏉″疄鐜扮殑-閭f垜浠氨鎶婂畠鍙仛宸ュ叿鏉¤彍鍗?menu toolbar)鍚? 鐒跺悗Command Bar灝嗙▼搴忓伐鍏鋒潯鐨勫浘鏍囪鍏mage list 騫跺皢瀹冧滑鐨処D淇濆瓨鍦ㄦ暟緇勪腑. 褰撶偣鍑誨伐鍏鋒潯鑿滃崟鐨勬寜閽椂,commandbar浼氭壘鍒板搴旂殑瀛愯彍鍗?鍒涘緩涓涓脊鍑鴻彍鍗? Command bar灝嗗瓙鑿滃崟欏圭殑ID鍜屽畠淇濆瓨鐨処D榪涜姣旇緝,榪欎簺ID璺焛mage list涓殑宸ュ叿鏉℃寜閽浘鏍囨槸鐩稿叧鑱旂殑. 濡傛灉姣旇緝鎴愬姛, 鍒欏皢鍏寵仈鐨勫浘鏍囧姞鍒拌彍鍗曢」涓婂幓. 榪欐剰鍛崇潃鐩稿悓ID鐨勮彍鍗曢」鍜屽伐鍏鋒潯鎸夐挳鍏鋒湁鐩稿悓鐨勫浘鏍?
鎺ヤ笅鏉? 鍒涘緩宸ュ叿鏉″茍鎶婂畠鍏寵仈鍒癱ommandbar, 鐒跺悗鍒涘緩鐘舵佹潯鍜岃鍥?鍙互鐪嬪埌瑙嗗浘鐨?b>HWND瀛樻斁鍦ㄦ鏋剁獥鍙g殑m_hWndClient鍙橀噺涓? 榪欎釜紿楀彛鍙ユ焺鍦ㄦ鏋剁獥鍙g殑WM_SIZE handler涓細鐢ㄥ埌.褰撴鏋剁獥鍙f敼鍙樺ぇ灝忔椂,瀹冨憡鐭ヨ鍥炬敼鍙樿嚜韜?浜庢鍚屾椂涔熻鑰冭檻鐘舵佹潯鍜宑ommand bar.
鍦ㄤ笅鏉ョ殑涓夎(浠庤皟鐢?b>UIAddToolBar()寮濮? 鐢ㄦ潵鏄劇ず鍦ㄨ繍琛屾椂浼氭敼鍙樼姸鎬佺殑UI欏?UI item).鏂囩珷鍚庨潰榪樹細閲嶆彁榪欎釜璇濋. 鏈鍚?璁塊棶娑堟伅寰幆(message loop), 浣犲簲璇ヨ繕璁板緱璇ユ秷鎭驚鐜瓨鏀懼湪涓鍏ㄥ眬鏁扮粍涓?GetMessageLoop() 鍙栧緱褰撳墠綰跨▼鐨勬秷鎭驚鐜?鍔犲叆妗嗘灦紿楀彛鐨刴essage filter鍜宨dle handler, 鍒嗗埆榛樿鏄?b>PreTranslateMessage()鍜?b>OnIdle().
妗嗘灦紿楀彛緇ф壙浜庝互涓嬬被:
class CMainFrame :
聽聽聽 public CFrameWindowImpl<CMainFrame>,
聽聽聽 public CUpdateUI<CMainFrame>,
聽聽聽 public CMessageFilter,
聽聽聽 public CIdleHandler
鍚庝袱涓娊璞$被瀹gО浜嗘鏋剁獥鍙g被瀹炵幇浜?b>PreTranslateMessage()鍜?b>OnIdle(). 浠?b>CUpdateUI<>緇ф壙琛ㄧず妗嗘灦綾繪敮鎸乁I update map.
瑙嗗浘
瑙嗗浘紿楀彛鐪嬭搗鏉?/span>鏄懼緱寰堢畝鍗?
class CMyView : public CWindowImpl<CMyView>
{
public:
聽聽聽 DECLARE_WND_CLASS(NULL)
聽聽聽 BOOL PreTranslateMessage(MSG* pMsg)
聽聽聽 {
聽聽聽 聽聽聽 pMsg;
聽聽聽聽聽聽聽 return FALSE;
聽聽聽 }
聽聽聽 BEGIN_MSG_MAP(CMyView)
聽聽聽聽聽聽聽 MESSAGE_HANDLER(WM_PAINT, OnPaint)
聽聽聽 END_MSG_MAP()
聽聽聽 LRESULT OnPaint(UINT, WPARAM, LPARAM, BOOL&)
聽聽聽 {
聽聽聽聽聽聽聽 CPaintDC dc(m_hWnd);
聽聽聽聽聽聽聽 //TODO: Add your drawing code here
聽聽聽聽聽聽聽 return 0;
聽聽聽 }
};
涓婇潰鏄?/span>涓涓猄DI紼嬪簭鐨勮鍥劇被. 澶氱嚎紼婼DI鍜孧DI鐨勮鍥劇被鍦ㄦ湰璐ㄤ笂涔?span lang="zh-cn">璺熻繖涓?/span>涓鏍?浣嗕粬浠病鏈?b>PreTranslateMessage()鏂規硶. SDI紼嬪簭灝辨槸浣跨敤榪欎釜鍑芥暟,璧跺湪妗嗘灦綾?span lang="zh-cn">澶勭悊娑堟伅涔嬪墠鎶婃秷鎭?/span>鎶撲綇. PreTranslateMessage()鍦⊿DI鐨勬鏋剁被涓殑瀹炵幇鏄?span lang="zh-cn">錛?/span>鐩存帴灝?/span>娑堟伅杞彂緇欒鍥劇被.
榪欓噷鏄劇ず鐨勮鍥懼疄闄呬笂娌℃湁鍋氫粈涔堝伐浣?浣犲簲璇?span lang="zh-cn">鑷繁鍦?b>OnPaint()鍑芥暟涓姞鍏ョ敾鍑烘枃妗?span lang="zh-cn">鍐呭鐨勪唬鐮?濡傛灉闇瑕佹敮鎸佽緭鍏?濡傞紶鏍囩殑鐐瑰嚮鍜岄敭鐩樼殑鎸夐敭,浣犲簲璇ュ姞鍏?span lang="zh-cn">鐩稿簲娑堟伅澶勭悊鍑芥暟鍒扮被鍜屾槧灝勪腑. 鍙互鐪?span lang="zh-cn">鍒?/span>榪欎釜紿楀彛鏄粠CWindowImpl<>緇ф壙涓嬫潵鐨?濡傛灉浣犳兂璁╁畠鍩轟簬涓涓猈in32鎺т歡鐨勮瘽,灝卞簲璇ヤ粠瀹氫箟鍦ˋtlCtrls.h鏂囦歡涓?span lang="zh-cn">鏌愪釜WTL綾葷戶鎵?
濡傛灉鎯沖湪鍩轟簬CWindowImpl<>鐨勭被閲屽姞涓婃粴鍔ㄦ潯,閭d箞浣犲簲璇ユ妸鍩虹被鎹㈡垚CScrollWindowImpl<>,鍚屾椂鎶婃秷鎭摼緇欏畠:
class CMyView : public CScrollWindowImpl<CMyView>
{
public:
聽聽聽 typedef CScrollWindowImpl<CMyView> parent;
聽聽聽 BEGIN_MSG_MAP(CMyView)
聽聽聽聽聽聽聽 CHAIN_MSG_MAP(parent)
聽聽聽 END_MSG_MAP()
聽聽聽 void DoPaint(CDCHandle dc)
聽聽聽 {
聽聽聽 }
}錛?/span>
鍩虹被淇濊瘉紿楀彛鍏?span lang="zh-cn">澶?/span>婊氬姩鏉?騫舵彁渚涙粴鍔ㄦ潯娑堟伅鐨勯粯璁ゅ鐞?瑙嗗浘綾諱笉鍐嶆湁WM_PAINT鐨勫鐞嗗嚱鏁?鍥犱負瀹?span lang="zh-cn">宸?/span>琚?b>CScrollWindowImpl<>澶勭悊.鏍規嵁婊氬姩鏉$殑浣嶇疆,CScrollWindowImpl<>鐢誨嚭瑙嗗浘鐩稿搴旂殑閮ㄥ垎. 鍙栬屼唬涔?span lang="zh-cn">鐨?/span>鏄?span lang="zh-cn">錛?/span>鍦ㄤ綘鐨勭被閲屽疄鐜?b>DoPaint(),鍦ㄨ繖閲屼綘闇瑕佺敾鍑?span lang="zh-cn">鏁?/span>涓鍥?濡傛灉浣?span lang="zh-cn">鎯?/span>鎸囧畾婊氬姩鐨勮寖鍥?澶у皬鎴栬搗鐐?浣犻渶瑕佸姞涓婂鐞?b>WM_CREATE娑堟伅鐨勫嚱鏁?span lang="zh-cn">錛屾妸榪欎簺鍒濆鍖?/span>浠g爜鏀懼埌閲岃竟.
姝e鎴戝厛鍓?span lang="zh-cn">鎵鎻愬埌鐨?妗嗘灦紿楀彛浼氭敼鍙樿鍥劇獥鍙g殑澶у皬,浠ヤ嬌瀹冨鎴峰尯鏈鐘舵佹潯鍜屽伐鍏鋒潯瑕嗙洊鐨勯儴鍒嗕負瑙嗗浘鎵濉厖. 鍦ㄥぇ澶氭暟鎯呭喌涓?榪欐牱灝卞浜?/span>.浣嗘槸褰撲綘鎯寵涓涓叿鏈塛indows Explorer鏍峰瓙鐨勭▼搴忔椂,璇ユ庝箞鍔炲憿? Windows Explorer鐨勭獥鍙e寘鍚簡涓涓猼ree view 鍜屼竴涓猯ist view,榪樻湁涓よ呬箣闂寸殑鍒嗗壊鏉? WTL鐨勮В鍐蟲柟妗堝緢綆鍗?浣跨敤splitter紿楀彛!
涓烘浣犻渶瑕佹敼鍙樹竴涓嬫鏋剁獥鍙?璁╁畠鍒涘緩splitter紿楀彛鐨勪竴涓疄渚嬩綔涓哄畠鐨勮鍥? 渚嬪, 鍦ㄤ綘鐨?span lang="zh-cn">妗嗘灦綾婚噷鏈夊涓嬬殑鏁版嵁鎴愬憳:
CSplitterWindow m_view;
CTreeViewCtrl m_tree;
CListViewCtrl m_list;
浣犲彲浠ュ湪OnCreate()鍒涘緩涓涓猻plitter紿楀彛:
// get the frame client rect, so that we set the splitter initial size
// and we can get the splitter bar in the centre
RECT rect;
GetClientRect(&rect);
m_hWndClient = m_view.Create(m_hWnd, rect,
聽聽聽 NULL, WS_CHILD | WS_VISIBLE);
m_tree.Create(m_view, rcDefault, NULL,
聽聽聽 WS_CHILD | WS_VISIBLE | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT,
聽聽聽 WS_EX_CLIENTEDGE);
m_list.Create(m_view, rcDefault,
聽聽聽 NULL, WS_CHILD | WS_VISIBLE | LVS_REPORT, WS_EX_CLIENTEDGE);
m_view.SetSplitterPanes(m_tree, m_list);
m_view.SetSplitterPos();
Splitter紿楀彛濡傚悓涓涓鍥?灝嗘鏋剁獥鍙d綔涓哄畠鐨勭埗紿楀彛. 鍦ㄨ繖孌典唬鐮侀噷,鎴戝皢妗嗘灦紿楀彛瀹㈡埛鍖虹殑瀹為檯澶у皬浼犵粰浜?/span>splitter紿楀彛. 鎴?span lang="zh-cn">涔?/span>鍙互鍦ㄨ繖閲屼嬌鐢?rcDefault,鍥犱負涓鏃︽鏋剁獥鍙?span lang="zh-cn">鍒涘緩瀹屾垚,妗嗘灦紿楀彛灝?/span>浼氳漿鍙?b>WM_SIZE娑堟伅緇檚plitter. 榪欐牱splitter鍙互椹笂鏀瑰彉鑷韓鐨勫ぇ灝忔潵濉厖妗嗘灦. 鐒惰?褰撴垜鍑嗗浣跨敤涓?span lang="zh-cn">甯?/span>鍙傛暟鐨?b>SetSplitterPos(),鎶婂垎鍓叉潯璁劇疆浜庣獥鍙d腑綰挎椂,鍑虹幇浜嗛棶棰?Splitter紿楀彛浣跨敤瀹冪殑澶у皬鏉ュ喅瀹氫腑綰跨殑浣嶇疆,鐢變簬rcDefault鍛婅瘔紿楀彛瀹冪殑澶у皬鏄?(鍥犳涓嚎鐨勪綅緗篃鏄?),浠庤屾剰鍛崇潃鍒嗗壊鏉″皢鍑虹幇鍦?span lang="zh-cn">z鏈宸﹁竟,灝?/span>宸︾獥鍙i殣钘忎簡璧鋒潵.
鍒涘緩浜唖plitter紿楀彛鍚?浣犻渶瑕佸垱寤洪偅浜涗綘鎯寵鍒嗗壊鐨勭獥鍙?span lang="zh-cn">浜?/span>.瀹冧滑灝嗕綔涓簊plitter紿楀彛鐨?span lang="zh-cn">瀛?/span>紿楀彛琚垱寤?鏈鍚庝綘灝嗚繖浜涘瓙紿楀彛閫氳繃SetSplitterPanes()鍔犲埌splitter紿楀彛涓幓,騫剁‘瀹氬垎鍓叉潯鐨勪綅緗墍鍦?
UI Update
鑿滃崟欏瑰彲浠ヨ璁劇疆涓烘湁鏁堟垨鏃犳晥,鍙互甯?/span>check璁板彿鎴栫潃鍍弐adio鎸夐挳涓鏍?鍦?/span>涓緇?span lang="zh-cn">鑿滃崟欏逛腑鍚屾椂鏈変笖鍙湁涓涓?span lang="zh-cn">鑳借check.姝ゅ,鑿滃崟欏硅繕鍙互甯﹀浘鏍囧拰鏂囧瓧. 鎵鏈夌殑榪欎簺鐘舵侀兘鍙互鍦ㄨ繍琛屾椂鏍規嵁紼嬪簭涓殑鏌愪釜鍊艱繘琛屾敼鍙?宸ュ叿鏉″湪鏌愮紼嬪害涓婂彲浠ョ湅鍋氭槸鑿滃崟鐨勬槗瑙佸艦鎬?鍥犱負瀹冧滑鐨勬寜閽彲浠ヤ釜鍒湴,鎴栬呬綔涓轟竴緇勭殑涓閮?span lang="zh-cn">鍒?/span>琚疆鎴愭湁鏁堟垨鏃犳晥,鎺ㄥ叆鎺ㄥ嚭. UI update鏈哄埗鍏佽浣犳寚瀹氬摢浜沀I鍏冧歡(UI element)鐨勭姸鎬佸彲浠ュ湪榪愯鏃舵敼鍙? WTL浣跨敤濡備笅鐨刄I update鏄犲皠鏉ュ疄鐜拌繖涓鍔熻兘:
BEGIN_UPDATE_UI_MAP(CMainFrame)
聽聽聽 UPDATE_ELEMENT(ID_FILE_SAVERESULTS, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
聽聽聽 UPDATE_ELEMENT(ID_VIEW_TOOLBAR, UPDUI_MENUPOPUP)
聽聽聽 UPDATE_ELEMENT(ID_VIEW_STATUS_BAR, UPDUI_MENUPOPUP)
END_UPDATE_UI_MAP()
榪欎釜渚嬪瓙鎸囧嚭涓変釜鑿滃崟欏瑰湪榪愯鏃舵湁涓涓姸鎬侀渶瑕佹樉紺?鍏朵腑鐨勪竴涓? ID_FILE_SAVERESULTS,榪?/span>鏈変竴涓伐鍏鋒潯鎸夐挳璺熷畠鐩稿叧鑱? WTL閫氳繃寤虹珛涓涓暟緇勬潵淇濆瓨榪欎簺淇℃伅.涓烘浣犻渶瑕?span lang="zh-cn">瀹屾垚涓ゆ柟闈㈢殑宸ヤ綔:
棣栧厛鏄疷I鍏冧歡鐨勭姸鎬? 濡傛灉鏄彍鍗曢」, 浣犲彲浠ヤ嬌鐢?b>UIEnable()浣胯兘璇ヨ彍鍗曢」, UISetCheck()璁劇疆check璁板彿, UISetText()鏀瑰彉鑿滃崟鐨勬枃瀛?濡傛灉鏄伐鍏鋒潯鎸夐挳,閭d箞浣犱嬌鐢?b>UIEnable()浣胯兘璇ユ寜閽? UISetCheck()鎴栬?font face="Courier New">UISetRadio()鍐沖畾鎸夐挳鏄帹鍏ヨ繕鏄帹鍑?涓嬭竟鐨勪唬鐮佹牴鎹槸鍚︽湁鏂囨湰琚変腑,鏉ヤ嬌鑳紺ut鑿滃崟欏瑰拰宸ュ叿鏉℃寜閽?
BOOL bSelected = GetSelected();
UIEnable(ID_EDIT_CUT, bSelected);
浣犲彲浠ユ妸榪欐牱鐨勪唬鐮佹斁鍏?span lang="zh-cn">鐩稿簲澶勭悊鍑芥暟涓?濡備竴涓彍鍗曢」鐨勭姸鎬?/span>渚濊禆浜庡彟涓涓彍鍗曢」鐨勫姩浣?span lang="zh-cn">,灝嗗畠鏀懼叆鍚庤呯殑澶勭悊鍑芥暟涓?/span>),鎴栬呮斁鍏?font face="Courier New">OnIdle()鏂規硶,閫氳繃媯鏌ユ煇涓被鍙橀噺鏉ュ喅瀹氬厓浠剁殑鐘舵?
鍏舵鏄‘瀹氬悇涓猆I鍏冧歡鏄惁閮借鏇存柊浜?涓烘浣犻渶瑕佽皟鐢?font face="Courier New">CUpdateUI<>鐨勬煇涓?/span>鏂規硶灝?/span>UI鍏冧歡鍔犲叆鍒板垪琛ㄤ腑.涓昏彍鍗曞凡琚?/span>鑷姩鍔犲叆,浣嗘槸鍏朵粬鐨勪換浣曡彍鍗曞拰鎵鏈夌殑宸ュ叿鏉″繀欏誨垎鍒氳繃璋冪敤UIAddMenuBar()鍜?b>UIAddToolBar()鎵嬪姩鍔犲叆.
鍏朵粬榪樻湁涓鍫嗕簨鎯呰娉ㄦ剰. 棣栧厛,璁劇疆浜嗗伐鍏鋒潯鐨勭姸鎬佸悗,浣跨敤UIUpdateToolBar()浠ヤ嬌宸ュ叿鏉$姸鎬佹洿鏂? 瀵逛簬鑿滃崟,浣犱笉闇濡傛,鍥犱負瀛愯彍鍗曟槸鍔ㄦ佺敓鎴愮殑.UIUpdateMenuBar()榪欎釜鏂規硶涔熷瓨鍦?浣嗘槸瀹?span lang="zh-cn">鐨勪綔鐢?/span>鏄妸鑿滃崟鎭㈠鍒板垵濮嬬姸鎬?濡傛灉浣犳敼鍙樿繃鏌愪簺欏圭殑鏂囧瓧,璋冪敤UIUpdateMenuBar()鐨勭粨鏋滃彲鑳戒笉鏄綘鎵鏈熸湜鐨?鍥犱負鑿滃崟欏圭殑鏂囧瓧浼氬彉鎴?span lang="zh-cn">鑰?/span>鐨?.
灝界榪樻湁涓涓柟娉?b>UISetRadio(),浣嗘槸榪?/span>娌℃湁涓涓妸鍑犱釜鑿滃崟欏規垨鑰呭伐鍏鋒潯鎸夐挳褰撳仛radio鎸夐挳緇?涔熷氨鏄,鏈変竴涓屼笖鍙湁涓涓閫変腑)鐨勬満鍒?濡傛灉浣犲笇鏈涘緱鍒拌繖鏍?span lang="zh-cn">鏁堟灉,浣犲繀欏昏嚜宸辯紪鐮?涓嶈繃瀹冨茍涓嶉毦.
瀵硅瘽妗?/font>
ATL鐨勫璇濇鏀寔涓鍚戝緢濂?瀵規WTL鏂板浜嗛氱敤瀵硅瘽妗嗙殑灝佽. 鏈川涓婃槸涓哄璇濇鍔犲叆浜嗚緭鍏ラ獙璇佸拰鍥炶皟鍑芥暟. 姣斿, 浣犳兂鍦?/span>鐢ㄦ埛鏀瑰彉騫碠pen瀵硅瘽妗嗕腑鐨勬枃浠跺す鏃舵湁鎵鍔ㄤ綔,閭d箞浣犲簲璇ヤ粠CFileDialogImpl<>緇ф壙涓涓被,瀹炵幇OnFolderChange():
class CMyFileDialog : public CFileDialogImpl<CMyFileDialog>
{
public:
聽聽聽 CMyFileDialog(BOOL b)
聽聽聽聽聽聽聽 : CFileDialogImpl<CMyFileDialog>(b) { }
聽聽聽 void OnFolderChange(LPOFNOTIFY lpon)
聽聽聽 {
聽聽聽聽聽聽聽 char strFolder[MAX_PATH];
聽聽聽聽聽聽聽 if (GetFolderPath(strFolder, sizeof(strFolder)) > 0)
聽聽聽聽聽聽聽 {
聽聽聽聽聽聽聽聽聽聽聽 MessageBox(strFolder);
聽聽聽聽聽聽聽 }
聽聽聽 }
};
褰撴枃浠跺す鐨勮礬寰勬敼鍙樻椂,CFileDialogImpl<>璋冪敤OnFolderChange().璇ュ嚱鏁頒嬌鐢ㄥ熀綾葷殑GetFolderPath(),鏉ュ彇寰楁柊璺緞.
鎺т歡
WTL涓烘墍鏈夌殑Win32鍜岄氱敤鎺т歡鎻愪緵浜嗗皝瑁呯被,鍖呮嫭Windows 2000鏂板姞鍏ョ殑. 铏界劧鍙槸綆鍗曠殑鍖呰錛屼絾鏄畠浠嬌榪欎簺鎺т歡鏇村姞瀹規槗璁塊棶.璀錛屼綘鑳借娓呮浠嶭ist View璇誨嚭褰撳墠閫夊畾欏圭殑鏂囧瓧鐨勬秷鎭拰闇瑕佷紶鐨勫弬鏁板悧錛?瀹為檯涓? 浣犻渶瑕佸彂閫佷袱涓秷鎭? 涓涓槸寰楀埌閫夊畾欏圭殑绱㈠紩錛屽彟涓涓槸璇誨嚭瀹冪殑鏂囧瓧.) WTL鐨勪綔鑰?span lang="zh-cn">涓轟綘瀹屾垚浜嗚繖浜涚儲浜虹殑宸ヤ綔, 鎻愪緵浜嗕竴涓畝鍗曠殑灝佽鍑芥暟渚涗綘浣跨敤.
浣跨敤榪欎簺鎺т歡綾繪湁涓ょ鏂規硶. 濡傛灉浣犵殑瀵硅瘽妗嗛噷鏈変竴涓帶浠? 浣犲彲浠ュ皢鎺т歡鐨?font face="Courier New">HWND渚濋檮鍒頒竴涓皝瑁呭璞?浣跨敤灝佽綾葷殑鏂規硶鏉ヨ闂帶浠?span lang="zh-cn">.榪欑鏂規硶綆鍖栦簡浣犺鍐欐帶浠舵暟鎹拰澶勭悊notification娑堟伅鐨勪唬鐮?
鍙﹀鐨勭敤娉曟槸鎶婅繖浜涚被鍔犲埌浣犵殑瑙嗗浘綾葷殑緇ф壙灞傛涓幓:
class CMyView : public CWindowImpl<CMyView, CListBox>
榪欒〃紺?font face="Courier New">CWindowImpl<>鏄?font face="瀹嬩綋">浠?/span>CListBox緇ф壙鑰屾潵,鍥犳鍒涘緩鐨勭獥鍙e皢鏄竴涓猯ist box (鍥犱負紿楀彛綾葷殑鍚嶅瓧鏄氳繃璋冪敤
CListBox::GetWndClassName()寰楀埌鐨?/span>). 鍙﹀, ATL鐨勭獥鍙f満鍒朵細瀛愮被鍖栬繖涓獥鍙?灝嗗彂緇欏畠鐨勬秷鎭礬鐢卞埌浣犵殑娑堟伅鏄犲皠涓幓. 瀹冧繚鐣欎簡鑰佺殑紿楀彛鍑芥暟,榪欐牱,浣犳病鏈夊鐞嗙殑娑堟伅灝嗙敱鑰佺殑紿楀彛鍑芥暟鏉ュ鐞?褰撲綘鐨勮鍥劇被浠庢帶浠剁被緇ф壙鏃?WTL灝變細浣跨敤榪欎竴鎶鏈?
鍦╪otification娑堟伅鍜屽瓙綾誨寲榪欎釜涓婚涓?鏈変竴鐐瑰緢鍊煎緱鎸囧嚭,閭e氨鏄綋鏌?/span>浜嬩歡鍙戠敓鏃?緇濆ぇ澶氭暟紿楀彛鎺т歡閮戒細鍙戦乶otification娑堟伅緇欏畠浠殑鐖剁獥鍙?璁╀綘紿楀彛鏉ュ鐞嗚繖浜?font face="Courier New">notification娑堟伅瑕佹瘮瀛愮被鍖栦竴涓凡瀛樺湪鎺т歡紿楀彛(鎴栧瓙綾誨寲涓涓凡瀛樺湪鐨勭被,鐒跺悗寤虹珛涓涓疄渚?,浠庤屽湪鎺т歡涔嬪墠鍙栧緱娑堟伅濂藉緱澶? 璀, 浣犳兂澶勭悊鎸夐挳鐨刢lick浜嬩歡,浣犳墍闇瑕佸仛鐨勫彧鏄鐞?font face="Courier New">BN_CLICKEDnotification.瀹冨皢鐢辨寜閽彂閫佺粰浣犵殑紿楀彛綾?鍙﹀鐨勪竴縐嶆柟娉曟槸浠?b>CContainedWindow<>瀛愮被鍖朆UTTON紿楀彛鏉ュ鐞?b>click娑堟伅.
鎴?span lang="zh-cn">涔嬫墍浠?/span>璇磋繖涓槸鍥犱負涓涓煡鍚嶇殑ATL榧撳惞鑰呯粰鎴戜竴浠戒唬鐮侀噷灝辨槸榪欎箞鍋氱殑.浠栫殑浠g爜鍙栧緱涓涓畝鍗曠殑鎸夐挳click浜嬩歡鎵鑺辯殑鏃墮棿鏄埆浜虹殑3鍒?鍊?鍥犱負浠栧瓙綾誨寲浜嗘寜閽帶浠?鑰屼笉鏄畝鍗曠殑澶勭悊BN_CLICKEDnotification.
WTL榪樻彁渚涗簡涓浜涙柊鐨勬帶浠?鍦╳in32涓病鏈夊絳夎? 浣犲凡緇忕湅鍒拌繃涓涓?span lang="zh-cn"> -- command bar, 瀹為檯涓婅繕鏈夊叾浠栦竴浜涢潪甯告湁鐢ㄧ被:
| 綾?/span> 聽聽 | 鎻忚堪 |
| CBitmapButton | 榪欐槸涓涓敤浣嶅浘鏇夸唬鏍囬鐨勬寜閽?浣犲彲浠ユ彁渚涗竴涓?/span>image list,閲岃竟鍖呭惈鎸夐挳鍦ㄦ甯哥姸鎬?澶辨晥, 鎺ㄥ叆鍜岄紶鏍囪惤鍦ㄦ寜閽笂鐨勫浘琛?/span>. |
| CHyperLink | 璁╀綘寤虹珛涓涓猻tatic鎺т歡,瀹冧唬琛ㄤ竴涓?/span>hyperlink,榪欐牱褰撶敤鎴風偣鍑誨畠鏃?榛樿鐨剋eb嫻忚鍣ㄦ墦寮璇ラ摼鎺?/span>. |
| CWaitCursor | 榪欎笉榪囨槸鍦ㄥ畠鐨勬瀯閫犲嚱鏁頒腑鎶婇紶鏍囧浘鏍囨敼鎴愮瓑寰呯姸鎬?鑰屽湪鏋愭瀯鍑芥暟涓繕鍘?/span>. |
| CCheckListViewCtrl | 鍦ㄦ瘡涓欏硅竟涓婇兘鏈変竴涓猚heck box鐨?/span>list box. |
| CMultiPaneStatusBarCtrl | 鍏鋒湁澶氫釜pane鐨勭姸鎬佹潯 |
聽