]]>Is MSDN wrong? or I made a mistake? about static member functionhttp://www.shnenglu.com/flyingxu/archive/2006/07/11/9697.htmlflyingxuflyingxuTue, 11 Jul 2006 11:14:00 GMThttp://www.shnenglu.com/flyingxu/archive/2006/07/11/9697.htmlhttp://www.shnenglu.com/flyingxu/comments/9697.htmlhttp://www.shnenglu.com/flyingxu/archive/2006/07/11/9697.html#Feedback3http://www.shnenglu.com/flyingxu/comments/commentRss/9697.htmlhttp://www.shnenglu.com/flyingxu/services/trackbacks/9697.htmlhttp://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.vc.mfc&tid=402a414c-a125-45bd-9cf4-c1819db7e3e4錛?br />
]]>Make header files self-sufficient鐨勪竴涓緥瀛?/title>http://www.shnenglu.com/flyingxu/archive/2006/06/23/8908.htmlflyingxuflyingxuFri, 23 Jun 2006 12:56:00 GMThttp://www.shnenglu.com/flyingxu/archive/2006/06/23/8908.htmlhttp://www.shnenglu.com/flyingxu/comments/8908.htmlhttp://www.shnenglu.com/flyingxu/archive/2006/06/23/8908.html#Feedback5http://www.shnenglu.com/flyingxu/comments/commentRss/8908.htmlhttp://www.shnenglu.com/flyingxu/services/trackbacks/8908.htmlIf one header file won't work unless the file that includes it also includes another header, that's gauche and puts unnecessary burden on that header file's users. 鍛靛懙錛岃嫳璇湁鐐規嫍鍙o紝鍚庨潰涓劇殑渚嬪瓙涔熼兘鏄ā鏉跨殑渚嬪瓙銆傛垜鍊掓槸閬囧埌榪囦竴涓疄闄呯殑渚嬪瓙錛岀畝鍖栧悗濡備笅錛?br />
鎯劎鍟?浠婂ぉ鎵嶇煡閬?浠婂ぉ鐪媠trtol鐨刴sdn鏂囨。,鐪嬪埌涓鍙ヨ瘽For both functions, errno is set to ERANGE if overflow or underflow occurs.,鎴戠湅浜嗗崐澶╂病鏈夋壘鍒癳rrno,鍚庢潵涓鎼?鎵嶅彂鐜板畠灞呯劧鏄釜鍏ㄥ眬鍙橀噺.
]]>浠涔堟椂鍊欏繀欏繪樉寮忚皟鐢ㄦ瀽鏋勫嚱鏁幫紵http://www.shnenglu.com/flyingxu/archive/2006/03/04/3702.htmlflyingxuflyingxuFri, 03 Mar 2006 16:35:00 GMThttp://www.shnenglu.com/flyingxu/archive/2006/03/04/3702.htmlhttp://www.shnenglu.com/flyingxu/comments/3702.htmlhttp://www.shnenglu.com/flyingxu/archive/2006/03/04/3702.html#Feedback6http://www.shnenglu.com/flyingxu/comments/commentRss/3702.htmlhttp://www.shnenglu.com/flyingxu/services/trackbacks/3702.html宸ヤ綔涓彂鐜扮殑 銆嬩腑錛屾彁鍒版瀽鏋勫嚱鏁板彲浠ヨ嚜宸辮皟鐢紝騫剁敤涓涓緥瀛愮紪璇戙佽繍琛岃瘉鏄庝簡銆?BR>鐜板湪鏈変釜闂錛岄櫎浜嗙煡閬撯滄瀽鏋勫嚱鏁?STRONG>鍙互鑷繁璋冪敤鈥濆錛岄偅涔堜粈涔堟椂鍊?STRONG>蹇呴』鏄懼紡璋冪敤鏋愭瀯鍑芥暟錛?BR> 鍏堢湅涓孌電幇瀹炵敓媧諱腑鐨勪唬鐮佸惂錛宮fc婧愮爜涓細
BOOL CStatusBar::AllocElements(int nElements, int cbElement) { // destruct old elements AFX_STATUSPANE* pSBP = _GetPanePtr(0); for (int i =0; i < m_nCount; i++) { pSBP->strText.~CString(); //娉ㄦ剰鐪嬭繖閲?/STRONG> ++pSBP; }
// allocate new elements if (!CControlBar::AllocElements(nElements, cbElement)) return FALSE;
// construct new elements pSBP = _GetPanePtr(0); for (i =0; i < m_nCount; i++) { memcpy(&pSBP->strText, &afxEmptyString, sizeof(CString)); ++pSBP; } return TRUE; }
BOOL CStatusBar::AllocElements(int nElements, int cbElement) { // destruct old elements AFX_STATUSPANE* pSBP = _GetPanePtr(0); for (int i =0; i < m_nCount; i++) { pSBP->strText.~CString(); //娉ㄦ剰鐪嬭繖閲?/SPAN> ++pSBP; }
// allocate new elements //if (!CControlBar::AllocElements(nElements, cbElement)) // return FALSE; //綆鍖栧悗鐨勪唬鐮侊紝瀹為檯榪愯鑲畾鏈夐棶棰橈紝浣嗘槸鍏抽敭涓滆タ鍑烘潵浜?/SPAN> free(pSBP);//娉ㄦ剰榪欓噷璋冪敤鐨勬槸free pSBP = calloc(nElements, cbElement);
// construct new elements pSBP = _GetPanePtr(0); //鏍規嵁mfc鐨勪唬鐮侊紝鍙互鐞嗚В榪欓噷鐨刾SBP鍜屽墠闈㈢殑pSBP榪樻槸鍚屼竴涓湴鍧 for (i =0; i < m_nCount; i++) { memcpy(&pSBP->strText, &afxEmptyString, sizeof(CString)); ++pSBP; } return TRUE; }
struct CStringData { long nRefs; // reference count int nDataLength; // length of data (including terminator) int nAllocLength; // length of allocation // TCHAR data[nAllocLength] TCHAR* data() // TCHAR* to managed data { return (TCHAR*)(this+1); } }; class CString { public: // Constructors // constructs empty CString CString(); // copy constructor CString(const CString& stringSrc); // from a single character CString(TCHAR ch, int nRepeat =1); // from an ANSI string (converts to TCHAR) CString(LPCSTR lpsz); // from a UNICODE string (converts to TCHAR) CString(LPCWSTR lpsz); // subset of characters from an ANSI string (converts to TCHAR) CString(LPCSTR lpch, int nLength); // subset of characters from a UNICODE string (converts to TCHAR) CString(LPCWSTR lpch, int nLength); // from unsigned characters CString(const unsigned char* psz); // Attributes & Operations