ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

C++¹Ø¼ü×Ö ÃæÊÔÌâ(Ò»)
2014-11-24 01:20:08 ¡¾´ó ÖРС¡¿ ä¯ÀÀ:339´Î
Tags£º¹Ø¼ü×Ö ÊÔÌâ

C++¹Ø¼ü×ÖÈ«¼¯ÕûºÏ
C++¹Ø¼ü×ÖÈ«¼¯(Õâ¸öÊÇ´ÓC++ Primer copy¹ýÀ´µÄ,ÓÐһЩ²¹³ä,Ò²ÓÐһЩÒѾ­±»Ìæ´ú):
asm auto bad_cast bad_typeid
bool break case catch
char class const const_cast
continue default delete do
double dynamic_cast else enum
except explicit extern false
finally float for friend
goto if inline int
long mutable namespace new
operator private protected public
register reinterpret_cast return short
signed sizeof static static_cast
struct switch template this
throw true try type_info
typedef typeid typename union
unsigned using virtual void
volatile wchar_t while
(1)asm
asmÒѾ­±»__asmÌæ´úÁË,ÓÃÓÚ»ã±àÓïÑÔǶÈëÔÚC/C++³ÌÐòÀï±à³Ì,´Ó¶øÔÚijЩ·½ÃæÓÅ»¯´úÂë.ËäÈ»ÓÃasm¹Ø¼ü×Ö±àÒëʱ±àÒëÆ÷²»»á±¨´í,µ«ÊÇasmÄ£¿éµÄ´úÂëÊÇûÓÐÒâÒåµÄ.


(2)auto
Õâ¸öÕâ¸ö¹Ø¼ü×ÖÓÃÓÚÉùÃ÷±äÁ¿µÄÉú´æÆÚΪ×Ô¶¯£¬¼´½«²»ÔÚÈκÎÀà¡¢½á¹¹¡¢Ã¶¾Ù¡¢ÁªºÏºÍº¯ÊýÖж¨ÒåµÄ±äÁ¿ÊÓΪȫ¾Ö±äÁ¿£¬¶øÔÚº¯ÊýÖж¨ÒåµÄ±äÁ¿ÊÓΪ¾Ö²¿±äÁ¿¡£Õâ¸ö¹Ø¼ü×Ö²»Ôõô¶àд£¬ÒòΪËùÓеıäÁ¿Ä¬ÈϾÍÊÇautoµÄ¡£


(3)bad_cast,const_cast,dynamic_cast,reinterpret_cast,static_cast
¹ØÓÚÒì³£´¦ÀíµÄ,»¹²»ÊÇÌ«Á˽â..


(4)bad_typeid
Ò²ÊÇÓÃÓÚÒì³£´¦ÀíµÄ,µ±typeid²Ù×÷·ûµÄ²Ù×÷ÊýtypeidΪNullÖ¸ÕëʱÅ׳ö.


(5)bool
²»Óöà˵ÁË°É,ÉùÃ÷²¼¶ûÀàÐ͵ıäÁ¿»òº¯Êý.


(6)break
Ìø³öµ±Ç°Ñ­»·.The break statement terminates the execution of the nearest enclosing loop or conditional statement in which it appears.


(7)case
switchÓï¾ä·ÖÖ§.Labels that appear after the case keyword cannot also appear outside a switch statement.


(8)catch,throw,try
¶¼ÊÇÒì³£´¦ÀíµÄÓï¾ä,The try, throw, and catch statements implement exception handling.


(9)char
ÉùÃ÷×Ö·ûÐͱäÁ¿»òº¯Êý.


(10)class
ÉùÃ÷»ò¶¨ÒåÀà»òÕßÀàµÄ¶ÔÏó.The class keyword declares a class type or defines an object of a class type.


(11)const
±»constÐÞÊεĶ«Î÷¶¼Êܵ½Ç¿ÖƱ£»¤£¬¿ÉÒÔÔ¤·ÀÒâÍâµÄ±ä¶¯£¬ÄÜÌá¸ß³ÌÐòµÄ½¡×³ÐÔ¡£Ëü¿ÉÒÔÐÞÊκ¯ÊýµÄ²ÎÊý¡¢·µ»ØÖµ£¬ÉõÖÁº¯ÊýµÄ¶¨ÒåÌå¡£
×÷ÓÃ:
1.ÐÞÊÎÊäÈë²ÎÊý
a.¶ÔÓÚ·ÇÄÚ²¿Êý¾ÝÀàÐ͵ÄÊäÈë²ÎÊý£¬Ó¦¸Ã½«¡°Öµ´«µÝ¡±µÄ·½Ê½¸ÄΪ¡°constÒýÓô«µÝ¡±£¬Ä¿µÄÊÇÌá¸ßЧÂÊ¡£ÀýÈ罫void Func(A a) ¸ÄΪvoid Func(const A &a)¡£
b.¶ÔÓÚÄÚ²¿Êý¾ÝÀàÐ͵ÄÊäÈë²ÎÊý£¬²»Òª½«¡°Öµ´«µÝ¡±µÄ·½Ê½¸ÄΪ¡°constÒýÓô«µÝ¡±¡£·ñÔò¼È´ï²»µ½Ìá¸ßЧÂʵÄÄ¿µÄ£¬ÓÖ½µµÍÁ˺¯ÊýµÄ¿ÉÀí½âÐÔ¡£ÀýÈçvoid Func(int x) ²»Ó¦¸Ã¸ÄΪvoid Func(const int &x)¡£
2.ÓÃconstÐÞÊκ¯ÊýµÄ·µ»ØÖµ
a.Èç¹û¸øÒÔ¡°Ö¸Õë´«µÝ¡±·½Ê½µÄº¯Êý·µ»ØÖµ¼ÓconstÐÞÊΣ¬ÄÇôº¯Êý·µ»ØÖµ£¨¼´Ö¸Õ룩µÄÄÚÈݲ»Äܱ»Ð޸ģ¬¸Ã·µ»ØÖµÖ»Äܱ»¸³¸ø¼ÓconstÐÞÊεÄͬÀàÐÍÖ¸Õë¡£
Èç¶ÔÓÚ£ºconst char * GetString(void);
ÈçÏÂÓï¾ä½«³öÏÖ±àÒë´íÎó£º
char *str = GetString();//cannot convert from ¡®const char *¡¯ to ¡®char *¡¯£»
ÕýÈ·µÄÓ÷¨ÊÇ£º
const char *str = GetString();
b.Èç¹ûº¯Êý·µ»ØÖµ²ÉÓá°Öµ´«µÝ·½Ê½¡±£¬ÓÉÓÚº¯Êý»á°Ñ·µ»ØÖµ¸´ÖƵ½ÍⲿÁÙʱµÄ´æ´¢µ¥ÔªÖУ¬¼ÓconstÐÞÊÎûÓÐÈκμÛÖµ¡£ Èç²»Òª°Ñº¯Êýint GetInt(void) д³Éconst int GetInt(void)¡£
3.const³ÉÔ±º¯ÊýµÄÉùÃ÷ÖУ¬const¹Ø¼ü×ÖÖ»ÄÜ·ÅÔÚº¯ÊýÉùÃ÷µÄβ²¿,±íʾ¸ÃÀà³ÉÔ±²»Ð޸ĶÔÏó.
˵Ã÷£º
const type m; //ÐÞÊÎmΪ²»¿É¸Ä±ä
ʾÀý£º
typedef char * pStr; //еÄÀàÐÍpStr;
char string[4] = ¡°abc¡±;
const char *p1 = string£»
p1++; //ÕýÈ·£¬ÉϱßÐÞÊεÄÊÇ*p1,p1¿É±ä
const pStr p2 = string;
p2++; //´íÎó£¬ÉϱßÐÞÊεÄÊÇp2£¬p2²»¿É±ä,*p2¿É±ä
ͬÀí£¬constÐÞÊÎÖ¸ÕëʱÓôËÔ­ÔòÅжϾͲ»»á»ìÏýÁË¡£


const int *value; //*value²»¿É±ä£¬value¿É±ä
int* const value; //value²»¿É±ä£¬*value¿É±ä
const (int *) value; //(int *)ÊÇÒ»ÖÖtype,value²»¿É±ä,*value¿É±ä
//Âß¼­ÉÏÕâÑùÀí½â£¬±àÒë²»ÄÜͨ¹ý£¬ÐèÒªtydef int* NewType;
const int* const value;//*value,value¶¼²»¿É±ä


(12)continue
½áÊøµ±Ç°Ñ­»·£¬¿ªÊ¼ÏÂÒ»ÂÖÑ­»·.Forces transfer of control to the controlling expression of the smallest enclosing do, for, or while loop.


(13)default
switchÓï¾äÖеÄĬÈÏ·ÖÖ§.None of the constants match the constants in the case labels; a default label is present.Control is transferred to the default label.


(14)delete
¾­³£ÓÃÓÚ¶¯Ì¬ÄÚ´æ·ÖÅäµÄÓï¾ä,Deallocates a block of memory.


(15)do
ÔÚdo-whileÑ­»·½á¹¹ÖпªÊ¼Ñ­»·Ìå.Executes a statement repeatedly until the specified termination condition (the expression) eva luates to zero.


(16)double
ÉùÃ÷Ë«¾«¶È±äÁ¿»òº¯Êý.


(17)else
Ìõ¼þÓï¾ä·ñ¶¨·ÖÖ§(Óë if Á¬ÓÃ).


(18)enum
ÉùÃ÷ö¾ÙÀàÐÍ.The name of each enumerator is treated as a constant and must be unique within the scope where the enum is defined.


(19)explicit
This keyword is a declaration specifier that can only be applied to in-class constructor declarations. An explicit constructor cannot take part in implicit conversions.

Ê×Ò³ ÉÏÒ»Ò³ 1 2 3 ÏÂÒ»Ò³ βҳ 1/3/3
¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
ÉÏһƪ£ºÃæÏò¶ÔÏó³ÌÐòÉè¼ÆÓë½á¹¹»¯³ÌÐòÉè.. ÏÂһƪ£ºÊ²Ã´ÊǹþÏ£±í£¿

×îÐÂÎÄÕÂ

ÈÈÃÅÎÄÕÂ

Hot ÎÄÕÂ

Python

C ÓïÑÔ

C++»ù´¡

´óÊý¾Ý»ù´¡

linux±à³Ì»ù´¡

C/C++ÃæÊÔÌâÄ¿