Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÉêÇëºóϵͳµÄÏìÓ¦
Õ»£ºÖ»ÒªÕ»µÄÊ£Óà¿Õ¼ä´óÓÚËùÉêÇë¿Õ¼ä£¬ÏµÍ³½«Îª³ÌÐòÌṩÄڴ棬·ñÔò½«±¨Òì³£ÌáʾջÒç³ö¡£
¶Ñ£ºÊ×ÏÈÓ¦¸ÃÖªµÀ²Ù×÷ϵͳÓÐÒ»¸ö¼Ç¼¿ÕÏÐÄÚ´æµØÖ·µÄÁ´±í£¬µ±ÏµÍ³ÊÕµ½³ÌÐòµÄÉêÇëʱ£¬»á±éÀú¸ÃÁ´±í£¬Ñ°ÕÒµÚÒ»¸ö¿Õ¼ä´óÓÚËùÉêÇë¿Õ¼äµÄ¶Ñ½áµã£¬È»ºó½«¸Ã½áµã´Ó¿ÕÏнáµãÁ´±íÖÐɾ³ý£¬²¢½«¸Ã½áµãµÄ¿Õ¼ä·ÖÅä¸ø³


Ïà¹ØÎĵµ£º

MATLABÓëC/C++»ìºÏ±à³ÌÖ®MATLABµ÷ÓÃC³ÌÐò

ͨ¹ý°ÑºÄʱ³¤µÄº¯ÊýÓÃcÓïÑÔʵÏÖ£¬²¢±àÒë³Émexº¯Êý¿ÉÒÔ¼Ó¿ìÖ´ÐÐËٶȡ£Matlab±¾ÉíÊDz»´øcÓïÑԵıàÒëÆ÷µÄ£¬ËùÒÔÒªÇóÄãµÄ»úÆ÷ÉÏÒѾ­°²×°ÓÐVC,BC»òWatcom CÖеÄÒ»ÖÖ¡£Èç¹ûÄãÔÚ°²×°MatlabʱÒѾ­ÉèÖùý±àÒëÆ÷£¬ÄÇôÏÖÔÚÄãÓ¦¸Ã¾Í¿ÉÒÔʹÓÃmexÃüÁîÀ´±àÒëcÓïÑԵijÌÐòÁË¡£Èç¹ûµ±Ê±Ã»ÓÐÑ¡£¬¾ÍÔÚMatlabÀï¼üÈëmex -setup£¬ÏÂÃæÖ»Òª¸ù¾ÝÌáʾ ......

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

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

(c primer plusµÚÎå°æ) ѧϰ±Ê¼Ç

µÚ¶þÕ cÓïÑÔ¸ÅÊö
Ò»¸ö¼òµ¥µÄʵÀý
#include <stdio.h>
int main(void)
{
   int num;   /*¶¨Òå±äÁ¿num*/
      num = 1;  /*¸ø±äÁ¿num¸³Öµ*/
 
      printf("I am a simple"); /*ʹÓÃprintf()º¯Êý*/
   & ......

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 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ