Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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++ ÓÉÓÚÖ§³ÖÖØÔØµÄÐèÒª£¬±àÒëºóµÄ·ûºÅà ......

Code::Blocks Âú×ãÄãÈκοÁ¿ÌµÄÒªÇóµÄC/C++ IDE


     Code::BlocksÊÇÒ»¸öÃâ·Ñ¡¢¿ªÔ´¡¢¿çƽ̨µÄIDE£¬Ê¹ÓÃC++¿ª·¢£¬²¢ÇÒʹÓÃwxWidgets×öΪGUIº¯ÊÔ¿â¡£Code::BlocksʹÓÃÁ˲å¼þ¼Ü¹¹£¬Æä¹¦ÄÜ¿ÉÒÔʹÓòå¼þ×ÔÓɵØÀ©³ä¡£Ä¿Ç°£¬ 
Code::BlocksÖ÷ÒªÕë¶Ô¿ª·¢C£¯C++³Ìʽ¶øÉè¼Æ¡£
ÓÉÓÚËü¿ª·ÅÔ´ÂëµÄÌØµã£¬WindowsÓû§¿ÉÒÔ²»ÒÀÀµÓÚVS.NET£¬±àд¿çƽ̨C++Ó¦Ó ......

Space C 2.1.2 ·¢²¼

--------Éý¼¶ Space C V2.1.2
2010.2.16
*½«Èí¼þ½çÃæ·ç¸ñÐÞ¸ÄΪ¸úËæWindowsϵͳ£¬ÃÀ»¯ÁËÈí¼þ½çÃæ£¬Ê¹¿ª·¢¹ý³Ì¸üÊæÐÄ¡£
*½«DOXBoxÐéÄâµÄ¿ªÆô/¹Ø±Õ£¬¸ü¸Äµ½±àÒëÅäÖеÄTC2.0Ò³Ãæ¡£
*Ôö¼Ó‘СÓïÑÔ’Tiny µÄ±àÒëÆ÷-Smmy£¬²¢¸½´øDOS°æµÄTMMY_DOSÐéÄâ»ú¡£
*Ôö¼Ó‘СÓïÑÔ’Tiny µÄ¶ÔÓ¦Windows°æÐéÄâ»úTMMY ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ