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

c/c++³ÌÐòµÄÄÚ´æ·ÖÅä [ת]

Ìâ¼Ç£º
ËùÓеÄÍêÃÀ£¬¶¼ÊÇÔÚ±ÀÀ£µÄÒ»¿Ì´ïµ½µÄ£¡
ÎÒÒ»Ö±»Ø±Ü³ÌÐòµÄÄÚ´æ¹ÜÀí£¬ÒòΪ°®Ö®ÓúÉºÞÖ®ÓúÁÒ¡£µ«ÊÇ£¬»¹ÊÇÓɺܶàµÄÅóÓÑÒ»Ö±ÔÚÌåÕâ·½ÃæµÄÎÊÌ⣬ËùÒÔ¾ÍË÷ÐÔ°ÑËü̹°×ÁË£¬Ò²Ðí¶ÔÄãÎÒ¶¼ÊÇÒ»¼þºÃÊÂÇé¡£
Ê×ÏÈ£¬ÐèÒª¸ãÇå³þ£º±äÁ¿µÄÀàÐͺÍËüµÄ´æ´¢Àà±ðÊÇÁ½¸ö¸ÅÄî¡£
Êý¾ÝÀàÐͺÍÄÚ´æ¹ÜÀíûÓÐÖ±½ÓµÄ¹Øϵ¡£
Ò»¸öÓÉc/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö£º
1¡¢Õ»Çø£¨stack£©— ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
2¡¢¶ÑÇø£¨heap£© — Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å£¬ Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ¡£×¢ÒâËüÓëÊý¾Ý½á¹¹ÖеĶÑÊÇÁ½»ØÊ£¬·ÖÅ䷽ʽµ¹ÊÇÀàËÆÓÚÁ´±í£¬ºÇºÇ¡£
3¡¢È«¾ÖÇø£¨¾²Ì¬Çø£©£¨static£©£¬È«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿µÄ´æ´¢ÊÇ·ÅÔÚÒ»¿éµÄ£¬³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿ÔÚÒ»¿éÇøÓò£¬ δ³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍδ³õʼ»¯µÄ¾²Ì¬±äÁ¿ÔÚÏàÁÚµÄÁíÒ»¿éÇøÓò¡£  ³ÌÐò½áÊøºóÓÉϵͳÊÍ·Å¡£
4¡¢ÎÄ×Ö³£Á¿Çø —³£Á¿×Ö·û´®¾ÍÊÇ·ÅÔÚÕâÀïµÄ¡£ ³ÌÐò½áÊøºóÓÉϵͳÊÍ·Å
5¡¢³ÌÐò´úÂëÇø—´æ·Åº¯ÊýÌåµÄ¶þ½øÖÆ´úÂë¡£
¶þ¡¢Àý×Ó³ÌÐò
ÕâÊÇÒ»¸öÇ°±²Ð´µÄ£¬·Ç³£Ïêϸ
//main.cpp
int a = 0; //È«¾Ö³õʼ»¯Çø
char *p1; //È«¾Öδ³õʼ»¯Çø
main()
{
int b; //Õ»
char s[] = "abc"; //Õ»
char *p2; //Õ»
char *p3 = "123456"; //123456\\0ÔÚ³£Á¿Çø£¬p3ÔÚÕ»ÉÏ¡£
static int c =0£» //È«¾Ö£¨¾²Ì¬£©³õʼ»¯Çø
p1 = (char *)malloc(10);
p2 = (char *)malloc(20);
·ÖÅäµÃÀ´µÃ10ºÍ20×Ö½ÚµÄÇøÓò¾ÍÔÚ¶ÑÇø¡£
strcpy(p1, "123456"); //123456\\0·ÅÔÚ³£Á¿Çø£¬±àÒëÆ÷¿ÉÄܻὫËüÓëp3ËùÖ¸ÏòµÄ"123456"ÓÅ»¯³ÉÒ»¸öµØ·½¡£
}
¶þ¡¢¶ÑºÍÕ»µÄÀíÂÛ֪ʶ
2.1ÉêÇ뷽ʽ
stack:
ÓÉϵͳ×Ô¶¯·ÖÅä¡£ ÀýÈ磬ÉùÃ÷ÔÚº¯ÊýÖÐÒ»¸ö¾Ö²¿±äÁ¿ int b; ϵͳ×Ô¶¯ÔÚÕ»ÖÐΪb¿ª±Ù¿Õ¼ä
heap:
ÐèÒª³ÌÐòÔ±×Ô¼ºÉêÇ룬²¢Ö¸Ã÷´óС£¬ÔÚcÖÐmallocº¯Êý
Èçp1 = (char *)malloc(10);
ÔÚC++ÖÐÓÃnewÔËËã·û
Èçp2 = (char *)malloc(10);
µ«ÊÇ×¢Òâp1¡¢p2±¾ÉíÊÇÔÚÕ»Öеġ£
2.2ÉêÇëºóϵͳµÄÏìÓ¦
Õ»£ºÖ»ÒªÕ»µÄÊ£Óà¿Õ¼ä´óÓÚËùÉêÇë¿Õ¼ä£¬ÏµÍ³½«Îª³ÌÐòÌṩÄڴ棬·ñÔò½«±¨Òì³£ÌáʾջÒç³ö¡£
¶Ñ£ºÊ×ÏÈÓ¦¸ÃÖªµÀ²Ù×÷ϵͳÓÐÒ»¸ö¼Ç¼¿ÕÏÐÄÚ´æµØÖ·µÄÁ´±í£¬µ±ÏµÍ³ÊÕµ½³ÌÐòµÄÉêÇëʱ£¬»á±éÀú¸ÃÁ´±í£¬Ñ°ÕÒµÚÒ»¸ö¿Õ¼ä´óÓÚËùÉêÇë¿Õ¼äµÄ¶Ñ½áµã£¬È»ºó½«¸Ã½áµã´Ó¿ÕÏнáµãÁ´±íÖÐɾ³ý£¬²¢½«¸Ã½áµãµÄ¿Õ¼ä·ÖÅä¸ø³


Ïà¹ØÎĵµ£º

ΧÆå´òÆ×Èí¼þÖÐ×Ô¶¯Ìá×Ó¹¦ÄܵÄʵÏÖ£¬C/C++Ô´Âë

±¾ÎÄÊ×·¢µØÖ·£ºhttp://blog.csdn.net/liigo/archive/2009/09/22/4582018.aspx
תÔØÇë×¢Ã÷³ö´¦£ºhttp://blog.csdn.net/liigo
×÷Õߣºliigo, 2009/09/22
¡¡¡¡ÔÚÏÂΧÆåʱ£¬µ±Ò»¸öÆå×ÓÂäµ½ÆåÅÌÉÏ£¬Ëü»á¶ÔÖÜΧ¶Ô·½Æå×ÓµÄËÀ»î²úÉúÓ°Ï죬Èç¹û¶Ô·½Æå×ÓûÓÐÆøÁË£¨ËÀÁË£©£¬±ØÐë´ÓÆåÅÌÉÏÄõô£¨Ìá×Ó£©¡£Õâ¸ö¹ý³ÌÌåÏÖµ½Î§ÆåÈí¼þÖУ¬¾ÍÐ ......

C/C++ÔËËã·ûµÄÓÅÏȼ¶


Precedence Operator Description Example Overloadable Associativity
1
::
Scope resolution operator
Class::age = 2;
no
none
2
()
()
[]
->
.
++
--
const_cast
dynamic_cast
static_cast
reinterpret_cast
typeid
Function call
Member initalization
Array access
Member access from ......

¸ßˮƽC³ÌÐòÔ±ÐÞÑø

ÔÚ´óÐÍCÓïÑÔÏîÄ¿¹¤³Ì»òÕßlinuxÄÚºËÖÐÎÒÃǶ¼»á¾­³£¼ûµ½Á½¸öFASTCALLºÍarmlinkage
Á½¸ö±êʶ·û(ÐÞÊηû)£¬ÄÇôËüÃǸ÷ÓÐʲô²»Í¬ÄØ£¿½ñÌì¾Í¸ø´ó¼Ò¹²Í¬·ÖÏíÒ»ÏÂ×Ô¼ºµÄÐĵÃ.
     ´ó¼Ò¶¼ÖªµÀÔÚ±ê×¼CϵÖк¯ÊýµÄÐβÎÔÚʵ¼Ê´«Èë²ÎÊýµÄʱºò»áÉæ¼°µ½²ÎÊý´æ·ÅµÄÎÊÌ⣬ÄÇôÕâЩ²ÎÊý´æ·ÅÔÚÄÄÀïÄØ£¿ ÓÐÒ»¶¨ÀíÂÛ»ù´¡µÄ ......

ѧϰlinuxϵÄc/c++±à³Ì

ѧϰlinuxϵÄc/c++±à³Ì  
1£¬ÏÈÓÐlinux»·¾³
´îminGWºÍcygwin¶¼ÓеãÂé·³£¬×î×î¼òµ¥µÄ°ì·¨»¹ÊÇ×°¸öÕæÕýµÄlinux£¬ÓÃÐéÄâ»úÒ²ºÃ£¬ÔÚÍøÂçÉϵÄÁíһ̨»úÆ÷Ò²ºÃ¡£ÕâÑù²»½ö¿ì£¬¶øÇÒÄãÓÐÁËÕæÕýµÄ»·¾³¡£
2.»áC/C++ÓïÑÔ£¨¹À¼ÆÄã»áµÄ£©
3.ÈëÃŽ׶ÎÊìϤgccÃüÁîÐУ¬×î»ù±¾µÄ²ÎÊý£¬È磬-g,-W,-O,-o,-c ½¨Òé¿´man gcc(ºÜ´óÕÒÏ ......

»ªÎªC/C++±ÊÊÔÌâ(¸½´ð°¸£¬»ªÎªÃæÊÔÌâϵÁÐ)

1.staticÓÐʲôÓÃ;£¿£¨ÇëÖÁÉÙ˵Ã÷Á½ÖÖ£©
    1)ÔÚº¯ÊýÌ壬һ¸ö±»ÉùÃ÷Ϊ¾²Ì¬µÄ±äÁ¿ÔÚÕâÒ»º¯Êý±»µ÷Óùý³ÌÖÐά³ÖÆäÖµ²»±ä¡£
    2) ÔÚÄ£¿éÄÚ£¨µ«ÔÚº¯ÊýÌåÍ⣩£¬Ò»¸ö±»ÉùÃ÷Ϊ¾²Ì¬µÄ±äÁ¿¿ÉÒÔ±»Ä£¿éÄÚËùÓú¯Êý·ÃÎÊ£¬µ«²»Äܱ»Ä£¿éÍâÆäËüº¯Êý·ÃÎÊ¡£ËüÊÇÒ»¸ö±¾µØµÄÈ«¾Ö±äÁ¿¡£
    ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ