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

c/c++_static±äÁ¿µÄÓ¦ÓÃ

ÔÚCÓïÑÔ±à³ÌÖУ¬staticµÄÒ»¸ö×÷ÓÃÊÇÐÅÏ¢ÆÁ±Î£¡
±È·½Ëµ£¬Äã×Ô¼º¶¨ÒåÁËÒ»¸öÎļþ -- ¸ÃÎļþÖÐÓÐһϵÁеĺ¯ÊýÒÔ¼°±äÁ¿µÄÉùÃ÷ºÍ¶¨Ò壡
ÄãÏ£Íû¸ÃÎļþÖеÄһЩº¯ÊýºÍ±äÁ¿Ö»Äܱ»¸ÃÎļþÖеĺ¯ÊýʹÓã¬ÄÇô£¬Äã¿ÉÒÔÔڸú¯Êý¡¢±äÁ¿µÄÇ°Ãæ¼ÓÉÏstatic£¬´ú±íËûÃÇÖ»Äܱ»µ±Ç°ÎļþÖеĺ¯ÊýʹÓã¡
¶øÔÚC++ÖУ¬ÓÃstaticÀ´×÷ΪÐÅÏ¢ÆÁ±Î¾ÍÏÔµÃûÓбØÒªÁË£¡ÒòΪ£¬C++ÓÐÁËÐÅÏ¢ÆÁ±ÎµÄÀûÆ÷ -- class»úÖÆ£¡
ÀàÖеÄprivateÊôÐԵıäÁ¿ºÍº¯Êý¾Í¶ÔÍâ½ûÖ¹·ÃÎÊ£¡
È»ºóÊÇC/C++ͨÓõĺ¯Êý×÷ÓÃÓòµÄstaticÐ͵ıäÁ¿£¡ÆäÄ¿µÄ£¬Ò²ÊÇΪÁËÐÅÏ¢µÄÆÁ±Î£¡
int fun() {
   static int a = 1;
   a++;
}
ÔÚµÚÒ»´Î½øÈëÕâ¸öº¯ÊýµÄʱºò£¬±äÁ¿a±»³õʼ»¯Îª1£¡²¢½Ó×Å×ÔÔö1£¡
ÒÔºóÿ´Î½øÈë¸Ãº¯Êý£¬a¾Í²»»á±»Ôٴγõʼ»¯ÁË£¬½ö½øÐÐ×ÔÔö1µÄ²Ù×÷£¡
ÔÚstatic·¢Ã÷ǰ£¬Òª´ïµ½Í¬ÑùµÄ¹¦ÄÜ£¬ÔòÖ»ÄÜʹÓÃÈ«¾Ö±äÁ¿£º
int a = 1;
int fun() {
   a++;
}
ÄÇô£¬aµÄÖµ¾ÍÓпÉÄܱ»ÆäËûº¯ÊýËù¸Ä±ä£¡
×îºó£¬ËµËµÀàÖеÄstatic±äÁ¿ºÍº¯Êý¡£
ÕâÖÖ´æ´¢ÊôÐԵıäÁ¿ºÍº¯ÊýÊÇͬһÖÖÀàµÄ²»Í¬ÊµÀýÖ®¼äͨÐŵÄÇÅÁº£¡
#include <iostream>
using namespace std;
class A {
public:
    static int num;    //    Í³¼Æ´´½¨Á˶àÉÙ¸öʵÀý
    A () {num++};    //    Ã¿´´½¨Ò»¸öʵÀý£¬¾ÍÈÃnum×ÔÔö1
    //    ·µ»ØÍ¨¹ý¹¹Ô캯ÊýËù´´½¨¹ýµÄAÀàʵÀýµÄÊýÄ¿
    static int how_many_instance() {
        return num;
    }
}
static A::num = 0;    //    ÐèÒªÔÚÀàÉêÃ÷µÄÍⲿµ¥¶À³õʼ»¯£¡
int main() {
    cout << A::how_many_instance() << endl;
    A a, b, c, d;
    cout << A::how_many_instance() << endl;
 


Ïà¹ØÎĵµ£º

C »ã±à»ìºÏ±à³Ì

As is Known to us,the function Main is the entry point of all programs.Therefore, we are usually neglecting all that we don't do,which makes us not understanding it more clearly.Now there is a sample arm program which will provide something that opration system usually do.
asm:
 &nb ......

C/C++ÖÐ×óÖµºÍÓÒÖµµÄ²î±ð

ÎÒÃdz£ËµµÄ×óÖµlvalueºÍÓÒÖµrvalue²¢²»¼òµ¥µØÒâζ×Å×óÓÒÇø±ð£¬ËüµÄԭʼ¶¨ÒåÈçÏ£º
Definition:
C and C++ have the notion of lvalues and rvalues associated with
variables and constants. The rvalue is the data value of the variable,
that is, what information it contains. The "r" in rvalue can ......

extern C µÄ×÷ÓÃ

extern "C" ÊÇ C++ ±àÒëÆ÷Ö§³ÖµÄÒ»ÖÖÁ´½Óָʾ·û£¨linkage directive£©£¬Ëü±íʾÓÉÆäÉùÃ÷µÄº¯ÊýʹÓà C ÓïÑԵķ½Ê½±àÒëºÍÁ´½Ó¡£
C ºÍ C++ ¶Ôº¯Êý±àÒëºó²úÉúµÄ·ûºÅÃûÊDz»Ò»ÑùµÄ¡£¼ÙÉèÒ»¸öº¯ÊýµÄÔ­ÐÍΪ:
void foo(int x, int y);
ÓÉ C ±àÒëÆ÷±àÒëºó²úÉúµÄ·ûºÅÃûΪ _foo£¬¶ø C++ ÓÉÓÚÖ§³ÖÖØÔØµÄÐèÒª£¬±àÒëºóµÄ·ûºÅà ......

C 1X ÐÂÔöÌØÐÔ


C1XÊÇCÓïÑÔ¼´C99±ê×¼Ö®ºó½«ÒªÍƳöµÄ×îбê×¼£¬Á˽⵽µÃÔ­ÎÄÈçÏ£º
C1X is the unofficial name of the planned new standard for the C programming language. It is intended to replace the existing C standard. This predecessor is informally known as C99. The standard is not yet fin ......

LinuxÇý¶¯¿ª·¢Ö®S3C2440°´¼üµãÁÁLED

ÎÄռǼÁË×÷ÕßÔÚS3C2440¿ª·¢°åÉÏʵÏÖ°´¼üµãÁÁLEDÇý¶¯¿ª·¢µÄÏêϸ¹ý³Ì£¬»¹¼Ç¼ÁËһЩÈÝÒ׳öÏֵĴíÎó£¬ÒÔ¼°Ôõô½â¾öÕâЩ´íÎó¡£
Ò»¡¢Çý¶¯¿ª·¢Á÷³Ì
       LinuxÇý¶¯¿ª·¢²»Í¬ÓÚÓ¦ÓóÌÐòµÄ¿ª·¢¡£Çý¶¯¿ª·¢ÊÇÖ±½ÓºÍÓ²¼þ´ò½»µÀµÄ£¬Í¨¹ý¶ÔÓ²¼þµÄ²Ù×÷¸øÓ¦ÓóÌÐòÌṩһЩ½Ó¿Úº¯Êý£¬Ê¹µÃÓ¦ÓóÌÐòÄܹ»&l ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ