¾µäC/C++ÃæÊÔÌ⣨¶þ£©
char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << boolalpha << ( str1==str2 ) << endl; // Êä³öʲô£¿
cout << boolalpha << ( str3==str4 ) << endl; // Êä³öʲô£¿
cout << boolalpha << ( str5==str6 ) << endl; // Êä³öʲô£¿
2. ·ÇC++ÄÚ½¨Ðͱð A ºÍ B£¬ÔÚÄļ¸ÖÖÇé¿öÏÂBÄÜÒþʽת»¯ÎªA£¿[C++ÖеÈ]
´ð£º
a. class B : public A { ……} // B¹«Óм̳Ð×ÔA£¬¿ÉÒÔÊǼä½Ó¼Ì³ÐµÄ
b. class B { operator A( ); } // BʵÏÖÁËÒþʽת»¯ÎªAµÄת»¯
c. class A { A( const B& ); } // AʵÏÖÁËnon-explicitµÄ²ÎÊýΪB£¨¿ÉÒÔÓÐÆäËû´øĬÈÏÖµµÄ²ÎÊý£©¹¹Ô캯Êý
d. A& operator= ( const A& ); // ¸³Öµ²Ù×÷£¬Ëä²»ÊÇÕý×ÚµÄÒþʽÀàÐÍת»»£¬µ«Ò²¿ÉÒÔÃãÇ¿ËãÒ»¸ö
3. ÒÔÏ´úÂëÖеÄÁ½¸ösizeofÓ÷¨ÓÐÎÊÌâÂð£¿[CÒ×]
void UpperCase( char str[] ) // ½« str ÖеÄСд×Öĸת»»³É´óд×Öĸ
{
for( size_t i=0; i<sizeof(str)/sizeof(str[0]); ++i )
if( 'a'<=str[i] && str[i]<='z' )
str[i] -= ('a'-'A' );
}
char str[] = "aBcDe";
cout << "str×Ö·û³¤¶ÈΪ: " << sizeof(str)/sizeof(str[0]) << endl;
UpperCase( str );
cout << str << endl;
int func(x)
{
int countx = 0;
while(x)
{
countx ++;
x = x&(x-1);
}
return countx;
}
¼Ù¶¨x =&n
Ïà¹ØÎĵµ£º
ÔÙÉÏһƪ£¬ÎÒÃǽéÉÜÁË»ù±¾µ÷ÊÔ¡£Ö®Ç°Ò²ËµÁË£¬Ö®ËùÒ԰ѵ÷ÊÔ·ÅÔÚÇ°Ãæ½²ÊÇÒòΪºóÃæµÄÎÄÕ»ù±¾¶¼»áÓõ½µ÷ÊÔ¡£¹Û²ìÎÒÃǵijÌÐòµ½µ×·¢ÉúÁËʲô¡£ÈÃÎÒÃÇÄܹ»Ö±½ÓÃ÷Á˵Ŀ´Çå³þÎÊÌâµÄ±¾ÖÊ¡£±¾Æª½«ÉîÈëÒ»µã½éÉÜÖ¸ÕëÕâ¸öÈÃÎÞÊý³õѧÕßη¾åµÄ¶«Î÷¡£Ï£Íû´ó¼ÒÔÙ¿´Í걾ƪ֮ºóÄܶÔÖ¸ÕëÓÐеÄÈÏʶ£¬Ö®ºó²»ÔÙ¾åÅÂËü¡£¾õµÃËü¾ÍÄÇô»ØÊ¡£ÄÇÏÂÃæÎÒ ......
×î½üά»¤Logger¹²Ïí¿âµÄʱºòÐÂÔöÁ˸üÈËÐÔ»¯µÄ×Ô¶¯´´½¨¸÷¼¶Ä¿Â¼µÄ¹¦ÄÜ£¬ÏÂÃæÊÇÎÒʵÏÖ´´½¨ÖîÈç "c:\a\b\c\d\yeah.log"Öеĸ÷¼¶Îļþ¼ÐµÄ¹ý³Ì£¬Çë´ó¼ÒÖ¸½Ì£¡
BOOL CreateDirectoryInPathW(const wchar_t *sLogPath)
{
static BOOL bRet = 0;
CString csFullDir(_T(""));//Ôʼȫ·¾¶
int nLen = 0;//ÔÊ ......
±í´ïʽµÄ¸±×÷ÓÃ
ÔËËã·ûµÄÓÅÏȼ¶Óë½áºÏÐԹ涨Á˱í´ïʽÖÐÏàÁÚÁ½¸öÔËËã·ûµÄÔËËã´ÎÐò£¬µ«¶ÔÓÚË«Ä¿
ÔËËãµÄ²Ù×÷Êý£¬C++ûÓй涨ËûÃǵļÆËã´ÎÐò¡£ÀýÈ磬¶ÔÓÚ±í´ïʽ£º
exp1 + exp2;
ÏȼÆËã exp1 »¹ÊÇ exp2£¿²»Í¬µÄ±àÒëÆ÷Óв»Í¬µÄ×ö·¨¡£
ÔÚÊýѧÉÏ£¬¶ÔÓÚË«Ä¿ÔËËã·û£¬²»ÂÛÏȼÆËãÄÄÒ»¸ö²Ù×÷Êý£¬ÒªÇó×îÖÕ¼ÆËã½á¹ûÒ»Ñù¡£
ÔÚ C ......
ÔÚÌÖÂÛÈ«¾Ö±äÁ¿Ö®Ç°ÎÒÃÇÏÈÒªÃ÷°×¼¸¸ö»ù±¾µÄ¸ÅÄ
1. ±àÒëµ¥Ôª(Ä£¿é)£º
ÔÚIDE¿ª·¢¹¤¾ß´óÐÐÆäµÀµÄ½ñÌ죬¶ÔÓÚ±àÒëµÄһЩ¸ÅÄîºÜ¶àÈËÒѾ²»ÔÙÇå³þÁË£¬ºÜ¶à³ÌÐòÔ±×îŵľÍÊÇ´¦ÀíÁ¬½Ó´íÎó(LINK ERROR), ÒòΪËü²»Ïñ±àÒë´íÎóÄÇÑù¿ÉÒÔ¸ø³öÄã³ÌÐò´íÎóµÄ¾ßÌåλÖã¬Äã³£³£¶ÔÕâÖÖ´íÎó¸Ðµ½°ÃÄÕ£¬µ«ÊÇÈç¹ûÄ ......
£¨±¾ÎÄÊÕ¼¯ÖÁÍøÂ磩
1.½éÉÜÒ»ÏÂSTL£¬Ïêϸ˵Ã÷STLÈçºÎʵÏÖvector¡£
STL (±ê׼ģ°æ¿â£¬Standard Template Library)ËüÓÉÈÝÆ÷Ëã·¨µü´úÆ÷×é³É¡£
STLÓÐÒÔϵÄһЩÓŵ㣺
¿ÉÒÔ·½±ãÈÝÒ×µØʵÏÖËÑË÷Êý¾Ý»ò¶ÔÊý¾ÝÅÅÐòµ ......