Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

(ת)C/C++ ºêÏê½â

ÖÚ¶àC++Êé¼®¶¼ÖÒ¸æÎÒÃÇCÓïÑÔºêÊÇÍò¶ñÖ®Ê×£¬µ«ÊÂÇé×ܲ»ÈçÎÒÃÇÏëÏóµÄÄÇô»µ£¬¾ÍÈçͬgotoÒ»Ñù¡£ºêÓÐ
Ò»¸öºÜ´óµÄ×÷Ó㬾ÍÊÇ×Ô¶¯ÎªÎÒÃDzúÉú´úÂë¡£Èç¹û˵ģ°å¿ÉÒÔΪÎÒÃDzúÉú¸÷ÖÖÐͱðµÄ´úÂë(ÐͱðÌæ»»)£¬
ÄÇôºêÆäʵ¿ÉÒÔΪÎÒÃÇÔÚ·ûºÅÉϲúÉúеĴúÂë(¼´·ûºÅÌæ»»¡¢Ôö¼Ó)¡£
¹ØÓÚºêµÄһЩÓï·¨ÎÊÌ⣬¿ÉÒÔÔÚgoogleÉÏÕÒµ½¡£ÏàÐÅÎÒ£¬Äã¶ÔÓÚºêµÄÁ˽â¾ø¶ÔûÄãÏëÏóµÄÄÇô¶à¡£Èç¹ûÄã
»¹²»ÖªµÀ#ºÍ##£¬Ò²²»ÖªµÀprescan£¬ÄÇôÄã¿Ï¶¨¶ÔºêµÄÁ˽ⲻ¹»¡£
ÎÒÉÔ΢½²½âϺêµÄһЩÓï·¨ÎÊÌâ(˵Óï·¨ÎÊÌâËƺõ²»Í×£¬macroÖ»ÓëpreprocessorÓйأ¬¸úÓïÒå·ÖÎöÓÖÎÞ¹Ø)£º
1. ºê¿ÉÒÔÏñº¯ÊýÒ»Ñù±»¶¨Ò壬ÀýÈ磺
#define min(x,y) (x µ«ÊÇÔÚʵ¼ÊʹÓÃʱ£¬Ö»Óе±Ð´ÉÏmin()£¬±ØÐë¼ÓÀ¨ºÅ£¬min²Å»á±»×÷ΪºêÕ¹¿ª£¬·ñÔò²»×öÈκδ¦Àí¡£
2. Èç¹ûºêÐèÒª²ÎÊý£¬Äã¿ÉÒÔ²»´«£¬±àÒëÆ÷»á¸øÄ㾯¸æ(ºê²ÎÊý²»¹»)£¬µ«ÊÇÕâ»áµ¼Ö´íÎó¡£ÈçC++Êé¼®ÖÐËùÃè
ÊöµÄ£¬±àÒëÆ÷(Ô¤´¦ÀíÆ÷)¶ÔºêµÄÓï·¨¼ì²é²»¹»£¬ËùÒÔ¸ü¶àµÄ¼ì²éÐÔ¹¤×÷µÃÄã×Ô¼ºÀ´×ö¡£
3. ºÜ¶à³ÌÐòÔ±²»ÖªµÀµÄ#ºÍ##
#·ûºÅ°ÑÒ»¸ö·ûºÅÖ±½Óת»»Îª×Ö·û´®£¬ÀýÈ磺
#define STRING(x) #x
const char *str = STRING( test_string ); strµÄÄÚÈݾÍÊÇ"test_string"£¬Ò²¾ÍÊÇ˵#»á°ÑÆäºóµÄ·ûºÅ
Ö±½Ó¼ÓÉÏË«ÒýºÅ¡£
##·ûºÅ»áÁ¬½ÓÁ½¸ö·ûºÅ£¬´Ó¶ø²úÉúеķûºÅ(´Ê·¨²ã´Î)£¬ÀýÈ磺
#define SIGN( x ) INT_##x
int SIGN( 1 ); ºê±»Õ¹¿ªºó½«³ÉΪ£ºint INT_1;
4. ±ä²Îºê£¬Õâ¸ö±È½Ï¿á£¬ËüʹµÃÄã¿ÉÒÔ¶¨ÒåÀàËƵĺ꣺
#define LOG( format, ... ) printf( format, __VA_ARGS__ )
LOG( "%s %d", str, count );
__VA_ARGS__ÊÇϵͳԤ¶¨Òåºê£¬±»×Ô¶¯Ì滻Ϊ²ÎÊýÁÐ±í¡£
5. µ±Ò»¸öºê×Ô¼ºµ÷ÓÃ×Ô¼ºÊ±£¬»á·¢Éúʲô£¿ÀýÈ磺
#define TEST( x ) ( x + TEST( x ) )
TEST( 1 ); »á·¢Éúʲô£¿ÎªÁË·ÀÖ¹ÎÞÏÞÖƵݹéÕ¹¿ª£¬Óï·¨¹æ¶¨£¬µ±Ò»¸öºêÓöµ½×Ô¼ºÊ±£¬¾ÍÍ£Ö¹Õ¹¿ª£¬Ò²¾ÍÊÇ
˵£¬µ±¶ÔTEST( 1 )½øÐÐÕ¹¿ªÊ±£¬Õ¹¿ª¹ý³ÌÖÐÓÖ·¢ÏÖÁËÒ»¸öTEST£¬ÄÇô¾Í½«Õâ¸öTESTµ±×÷Ò»°ãµÄ·ûºÅ¡£TEST(1)
×îÖÕ±»Õ¹¿ªÎª£º1 + TEST( 1) ¡£
6. ºê²ÎÊýµÄprescan£¬
µ±Ò»¸öºê²ÎÊý±»·Å½øºêÌåʱ£¬Õâ¸öºê²ÎÊý»áÊ×Ïȱ»È«²¿Õ¹¿ª(ÓÐÀýÍ⣬¼ûÏÂÎÄ)¡£µ±Õ¹¿ªºóµÄºê²ÎÊý±»·Å½øºêÌåʱ£¬
Ô¤´¦ÀíÆ÷¶ÔÐÂÕ¹¿ªµÄºêÌå½øÐеڶþ´ÎɨÃ裬²¢¼ÌÐøÕ¹¿ª¡£ÀýÈ磺
#define PARAM( x ) x
#define ADDPARAM( x ) INT_##x
PARAM( ADDPARAM( 1 ) );
ÒòΪADDPARAM( 1 ) ÊÇ×÷ΪPARAMµÄºê²ÎÊý£¬ËùÒÔÏȽ«ADDPARAM( 1 )Õ¹¿ªÎªINT_1£¬È»ºóÔÙ½«INT_1·Å½øPARA


Ïà¹ØÎĵµ£º

ÎÄ˼´´ÐÂÈí¼þ·þÎñ²¿11ÔÂ×îÐÂְλ¸üРjava c++

ÎÄ˼ÐÅÏ¢¼¼ÊõÓÐÏÞ¹«Ë¾www.vanceinfo.com£¨Å¦½»ËùÉÏÊдúÂ룺VIT£©³ÉÁ¢ÓÚ1995Ä꣬ÊÇÒ»¼ÒÐÅÏ¢¼¼Êõ·þÎñÌṩÉ̼°ÔÚÖйú¾ÓÁìÏȵØλµÄÀë°¶Èí¼þ¿ª·¢¹«Ë¾Ö®Ò»¡£ÎÄ˼ÊǵÚÒ»¼ÒÔÚŦԼ¹ÉƱ½»Ò×ËùÉÏÊеÄÖйúÈí¼þ·þÎñÍâ°üÆóÒµ¡£¾Ý¹ú¼ÊÊý¾Ý¹«Ë¾(IDC)µÄͳ¼Æ, ÒÔ2007ÄêÏúÊÛ¶îºâÁ¿, ÎÄ˼ÐÅÏ¢¼¼ÊõÔÚΪŷÃÀÊг¡ÌṩÀë°¶Èí¼þ¿ª·¢ÐÐÒµÖÐλ¾ÓÖйúµÚÒ ......

C Sharp(C#)ÖÐÈçºÎɾ³ýÎļþ(Îļþ¼Ð)

C Sharp(C#)ÖÐÈçºÎɾ³ýÎļþ(Îļþ¼Ð)
Ö±½Óɾ³ý:
using System.IO;
...
string filePath = @"D:\...\xxx.xxx";

if (File.Exists(filePath))
{
File.Delete(filePath);
}
else
{
Console. ......

C/C++µÄÌõ¼þ±àÒë

ÒÔΪÒѾ­ÕÆÎÕÌõ¼þ±àÒ룬Ԥ±àÒëµÄÒªÁìÁË£¬½á¹û»¹ÊÇ´æÔںܶàÒÅ©µÄµØ·½£¬ËùÒÔ¹æÕûһϣº
Ìõ¼þ±àÒ룺
1
#ifdef _XXXX
...³ÌÐò¶Î1...
#else
...³ÌÐò¶Î2...
#endif
  Õâ±íÃ÷Èç¹û±êʶ·û_XXXXÒѱ»#defineÃüÁÒå¹ýÔò¶Ô³ÌÐò¶Î1½øÐбàÒ룻·ñÔò¶Ô³ÌÐò¶Î2½øÐбàÒë¡£
2
#ifndef _XXXX
...³ÌÐò¶Î1...
#else
...³ÌÐ ......

cÓëc++ staticº¯ÊýµÄÇø±ð

 
cÓëc++ staticº¯ÊýµÄÇø±ð

c
Óëc++ static
º¯ÊýµÄÇø±ð
static
¹Ø¼ü×ÖÊÇ
C, C++
Öж¼´æÔڵĹؼü×Ö
,
ËüÖ÷ÒªÓÐÈýÖÖʹÓ÷½Ê½
,
ÆäÖÐÇ°Á½ÖÖÖ»Ö¸ÔÚ
C
ÓïÑÔÖÐʹÓÃ
,
µÚÈýÖÖÔÚ
C++
ÖÐʹÓÃ
(C,C++
ÖоßÌåϸ΢²Ù×÷²»¾¡Ïàͬ
,
±¾ÎÄÒÔ
C++
Ϊ׼
).
(1)
¾Ö²¿¾²Ì¬±äÁ¿
(2)
Íⲿ¾²Ì ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ