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

C/C++ÖеÄstatic

C++ÖеÄStaticÓÐÁ½¸ö×÷Óá£
1¡¢ ¾²Ì¬¾Ö²¿±äÁ¿ 
   ¾²Ì¬¾Ö²¿±äÁ¿ÔÚº¯ÊýÄÚ¶¨Òå ËüµÄÉú´æÆÚΪÕû¸öÔ´³ÌÐò£¬µ«ÊÇÆä×÷ÓÃÓòÔڸú¯ÊýÄÚ£¬Ö»ÄÜÔÚ¶¨Òå¸Ã±äÁ¿µÄº¯ÊýÄÚʹÓøñäÁ¿¡£ ÔÊÐí¶Ô¹¹ÔìÀྲ̬¾Ö²¿Á¿¸³³õÖµ£¬Èôδ¸³ÒÔ³õÖµ£¬ÔòÓÉϵͳ×Ô¶¯¸³ÒÔ0Öµ¡£ 
void fun1()
{
static int i = 0;
cout << ++i << endl;
}
int main()
{
for(int i = 0; i < 5; i++)
{
fun1();
}

Output :
1
2
3
4
2¡¢¾²Ì¬È«¾Ö±äÁ¿ 
  È«¾Ö±äÁ¿Ç°ÔÙ¼ÓÉÏstatic ¾Í³ÉÁ˾²Ì¬µÄÈ«¾Ö±äÁ¿¡£È«¾Ö±äÁ¿±¾Éí¾ÍÊǾ²Ì¬´æ´¢·½Ê½£¬ ¾²Ì¬È«¾Ö±äÁ¿µ±È»Ò²ÊǾ²Ì¬´æ´¢·½Ê½¡£È«¾Ö±äÁ¿×÷ÓÃÓòÊÇÕû¸öÔ´³ÌÐò£¬¶ø¾²Ì¬È«¾Ö±äÁ¿×÷ÓÃÓòÈ·ÊǸÃÎļþ¡£¾²Ì¬º¯ÊýÀàËÆ¡£


Ïà¹ØÎĵµ£º

ÎÒµÄCʵ¼ù(2)£ºÁªºÏµÄÃîÓÃ

    ÔÚCÓïÑÔÖУ¬ÁªºÏÀàÐÍÊÇÒ»ÖֱȽÏÌØÊâµÄÀàÐÍ£¬Æä¶à¸ö³ÉÔ±¹²ÏíÒ»¸ö´æ´¢Çø£¨Îª×î´ó³ÉÔ±µÄ³¤¶È£©£¬Ò»´ÎÖ»ÄÜ°üº¬Ò»¸ö³ÉÔ±Öµ£¬»á½øÐÐÄÚ´æ¶ÔÆë¡£¶ÔÁªºÏÀàÐͽøÐÐsizeofÔËËã»á°üÀ¨ËùÓгÉÔ±ËùÐèÒªµÄ´æ´¢¿Õ¼äÁ¿£¬»¹°üÀ¨³ÉÔ±¼äºÍ³ÉÔ±ºóÃæµÄÌî³ä¿Õ¼ä¡£ÁªºÏÀàËÆÓÚÆäËûÓïÑÔÖеē±äÌå¼Ç¼”£¬Èç¹ûÁªºÏµÄ³¤¶ÈºÜ ......

³¤ÆÚÊÕ¼¯ C/C++ FAQ

дÔÚÇ°Ã棺
¡¡¡¡ÂÛ̳Àï×ÜÓÐÄÇôһЩÎÊÌâÊdz¤Ê¢²»Ë¥µÄ£¬½ñÌìÕâ¸öÎÊ£¬Ã÷ÌìÄǸöÎÊ£¬µ½ÀúÊ·Ìû×ÓÀïÒ»ËÑ¿ÉÒÔ×¥³öÀ´Ò»´ó°Ñ¡£ÓÐʱºòÕⶼÁîÎÒ»³ÒÉÊDz»ÊÇÎÒÃǵĽÌÓýÌåÖÆ´æÔÚÎÊÌâ……
¡¡¡¡ÓÚÊÇÎÒ¿ªÁËÕâƪÎÄÕ£¬ËѼ¯ÎÒ¼ûµ½µÄ³¤Éú²»ÀÏÖ®Ìû£¬Ï£Íû¿ÉÒÔÆ𵽲ο¼¼ÛÖµ¡£
¡¡¡¡ÕâÀïʹÓõıàÒë»·¾³Îª gcc/g++ 4.3.3 for ubuntu 9. ......

C ·ç¸ñ£¨C

C ·ç¸ñ£¨C-style£©Ç¿ÖÆתÐÍÈçÏ£º
(T) exdivssion // cast exdivssion to be of type T
º¯Êý·ç¸ñ£¨Function-style£©Ç¿ÖÆתÐÍʹÓÃÕâÑùµÄÓï·¨£º
T(exdivssion) // cast exdivssion to be of type T
 
ÕâÁ½ÖÖÐÎʽ֮¼äûÓб¾ÖÊÉϵIJ»Í¬£¬Ëü´¿´â¾ÍÊÇÒ»¸ö°ÑÀ¨ºÅ·ÅÔÚÄĵÄÎÊÌâ¡£ÎÒ°ÑÕâÁ½ÖÖÐÎʽ³ÆΪ¾É·ç¸ñ£¨old-style£ ......

CÓïÑÔÖÐûÓк¯ÊýÖØÔصĸÅÄî

CÓïÑÔÖÐûÓк¯ÊýÖØÔصĸÅÄ£¡
CÓïÑÔÖÐûÓк¯ÊýÖØÔصĸÅÄ£¡
½ñÌìMSNȺÖÐÓиöÈËÎÊÎÒCÓïÑÔµÄÎÊÌ⣺
     £¨Á½¸öº¯ÊýʵÏֵŦÄÜÏàͬ
       µ«ÊÇËüÃDzÎÊýµÄ¸öÊý²»Í¬
       ÎÒÓÃÒ»¸öº¯Êý°ÑÕâ¸öÁ½¸öº¯Êý·âÆðÀ´
  &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ