c/c++ÖеÄconst¹Ø¼ü×Ö
const£¬c\c++Öзdz£³£ÓõĹؼü×Ö¡£
Ê×ÏÈÎÒÃÇ¿´¿´constÓÐÄÇЩÐÞÊη½·¨¡£
×îÇ°ÃæÎÒÃÇÀ´¿´Ò»¸öÎÊÌâ¡£
char *p = "123";
¿ÉÄÜÓеÄÈ˲»ÖªµÀ£¬ÕâÀïµÄÕâ¸ö"123"ÊÇ´æ´¢ÔÚ³£Á¿ÇøµÄ£¬²»ÈÝÐíÐ޸ĵġ£
Ò²¾ÍÊÇ˵ËüÊǸöconstÀàÐ͵ġ£
±ê×¼µÄд·¨Ó¦¸ÃÊÇ
char const *p = "123";
ÖÁÓÚΪʲô±àÒëÆ÷ÈÝÐíÉÏÃæµÄÄǸö²»±ê×¼µÄд·¨£¬¿ÉÄÜÊÇÒòΪ¼æÈÝÐÔµÄÎÊÌâ°É¡£
char p[4] = "123";//Õâ¸öºÍÉÏÃæµÄ¿ªÊ¼´ó²»Ò»ÑùµÄ°¡¡£
ÇÐÈëÕýÌâ¡£
const int s = 0;
ÉÏÃæµÄºÜÈÝÒ×Àí½â¡£µ«´øÉÏÖ¸ÕëÓÐЩͬѧ¿ÉÄܾÍÒª»èÁË¡£
const int *p = &s;//£¨1£©
int const *p = &s;//£¨2£©
int * const p = &s;//£¨3£©
const int * const p = &s;//£¨4£©
£¨1£©ºÍ£¨2£©µÄЧ¹ûÊÇÒ»ÑùµÄ£¬Òâ˼ÊÇ p ÊǿɱäµÄ£¬µ«ÊÇ p Ö¸ÏòµÄÖµÊDz»¿É±äµÄ¡£
£¨3£©¾Í¸ÕºÃÏà·´£¬p ÊDz»¿É±äµÄ£¬Ö»ÄÜÖ¸ÏòÒ»¸öµØ·½£¬µ«ÊÇ p Ö¸ÏòµÄÖµÊǿɱäµÄ¡£
£¨4£©p²»¿É±ä£¬*p Ò²²»¿É±ä¡£
ÎÒÃǾٸöÀý×Ó¿´¿´¡£
int s = 0;
const int *p = &s;
p++;//¿ÉÒÔ
p--;//¿ÉÒÔ
*p = 4;//´íÎó
------------------------------
int s = 0;
int * const p = &s;
*p = 4;//¿ÉÒÔ
p++;//´íÎó
------------------------------
ÓеÄʱºòÎÒÃÇ»áʹÓÃtpyedef¡£
typedef char * pStr;
char str[4] = "123";
const char *p1 = str;// p1¿É±ä£¬*p1²»¿É±ä
const pStr p2 = str;// ºÍÉÏÃæµÄÒâ˼²»Ò»ÑùŶ£¬p2²»¿É±ä£¬*p2¿É±ä
p1++;//¿ÉÒÔ
p2++;//´íÎó
-------------------------------
ÓÐʱºòÎÒÃÇ»áʹÓÃÀ¨ºÅ
(int *) const p;//pÊDz»¿É±ä,*p¿É±ä
const (char *) p;//pÊDz»¿É±ä,*p¿É±ä
-----------------------------------------------------------
ÔÚcÖÐ ±»constÐÞÊεıäÁ¿²¢²»ÊÇÕýÕæÒâÒåÉϵij£Á¿£¬¶øÊÇÖ»¶ÁµÄ±äÁ¿£¬ÕâºÍ³£Á¿»¹Óв»ÉٵIJî¾àµÄ¡£
Ò²¾ÍÊÇ˵ÔÚÄÚ´æÖпª±ÙÒ»¸öÖ»¶ÁµÄ¿Õ¼ä´æÖüÕâ¸ö±äÁ¿£¬ÈçºÎ±£Ö¤Õâ¸ö¿Õ¼äÖ»¶ÁÊÇͨ¹ý±àÒëÆ÷ʵÏֵģ¬
µ±ÎÒÃÇÄÜƹý±àÒëÆ÷µÄʱºò£¬ÎÒÃǾÍÄܾÍÄÜÐÞ¸Äconst³£Á¿¡£
ÔÚc´úÂëÖÐд£º
const int num = 9;
int ary[num];
Õâ¶Î´úÂëÊDz»ÄÜͨ¹ý±àÒëµÄ£¬Èç¹ûÕæµÄÏëÕâô¸ÉÖ»ÄÜͨ¹ýºêÀ´ÊµÏÖÁË¡£
#define NUM = 9;
int ary[NUM];
´ó¼Ò¶¼ÖªµÀºêÌæ»»µÄһЩ±×¶Ë£¬±ÈÈ磺NUMûÓÐÀàÐÍ£¬´Ó´ËNUMÕâ¸öÃû×ÖÔÙҲûÓбðµÄÓÃ;¡£
-------------------------------------------------------------
¶øc++ÖеÄconst¾ÍÏȽøµÄ¶àÁË¡£ËûÊÇÔÚ±àÒëµÄʱºò¾ÍÒѾȷ¶¨Á˵ÄÖµ¡£
const int num = 9;
Ïà¹ØÎĵµ£º
C++ Boost¿â¼ò½é
boostÖ÷Òª°üº¬Ò»Ï¼¸¸ö´óÀࣺ×Ö·û´®¼°Îı¾´¦Àí¡¢ÈÝÆ÷¡¢µü´ú×Ó(Iterator)¡¢Ëã·¨¡¢º¯Êý¶ÔÏóºÍ¸ß½×±à³Ì¡¢·ºÐͱà³Ì¡¢Ä£°åÔª±à³Ì¡¢Ô¤´¦ÀíÔª±à³Ì¡¢²¢·¢±à³Ì¡¢ÊýѧÏà¹Ø¡¢¾À´íºÍ²âÊÔ¡¢Êý¾Ý½á¹¹¡¢ÊäÈë/Êä³ö¡¢¿çÓïÑÔÖ§³Ö¡¢ÄÚ´æÏà¹Ø¡¢Óï·¨·ÖÎö¡¢ÔÓÏî¡£ ÓÐһЩ¿âÊÇ¿çÀà±ð°üº¬µÄ£¬¾ÍÊǼÈÊôÓÚÕâ ......
---- ÔÚÓÃPowerBuilder¿ª·¢Ó¦ÓóÌÐòʱ£¬¾³£ÐèÒªµ÷Óö¯Ì¬Á´½Ó¿âDLL£¬±¾ÎĽéÉÜÁ˶¯Ì¬Á´½Ó¿âµÄ»ù±¾Ìص㣬¸ø³öÁËVC++½¨Á¢DLLÒÔ¼°ÔÚPowerBuilderÖе÷ÓÃVC++´´½¨µÄDLLº¯ÊýµÄ±à³ÌʵÀý£¬ÊµÏÖÁËͨ¹ýDLLÁ¬½ÓPowerBuilderºÍVC++±àÖƵIJ»Í¬³ÌÐòµÄÄ¿µÄ¡£
Ò»¡¢ DLL¸ÅÊö£º
---- ¶¯Ì¬Á´½Ó¿â£¨Dynamic-Link Library£©£¬¼ò³ÆDLL£¬ÊÇ»ùÓÚWin ......
ѧϰC++Äã±ØÐëÁ˽âÒÔÏÂ֪ʶ£º
C++Ö»ÊÇÒ»ÖÖÓïÑÔ¹¤¾ß£¬ÄãÒª±à³ÌÐò£¬×öÏîĿʵÏÖ×Ô¼ºµÄÏë·¨µ¥¿¿APIÊǺܷѾ¢µÄ£¬ÌرðÊÇÕë¶ÔÖØÁ¿¼¶µÄÏîÄ¿¡£ËùÒÔÔÚʵ¼Ê¹¤×÷ʱ£¬Äã±ØÐë»áÖÁÉÙ1ÖÖC++¿ª·¢¿â£¬ÕâÑùÄã»á¸ü¿ì¸üÓŵØÍê³ÉÒ»ÏîÈÎÎñ¡£
------------------------------------------------------------------------------------
ժ¼ÓÚ:http ......
C++Àà¿â½éÉÜ
ÔÙ´ÎÌåÏÖÁËC++±£³ÖºËÐÄÓïÑÔµÄЧÂÊͬʱ´óÁ¦·¢Õ¹Ó¦ÓÿâµÄ·¢Õ¹Ç÷ÊÆ!!ÔÚC++ÖУ¬¿âµÄµØλÊǷdz£¸ßµÄ¡£C++Ö®¸¸ Bjarne
StroustrupÏÈÉú¶à´Î±íʾÁËÉè¼Æ¿âÀ´À©³ä¹¦ÄÜÒªºÃ¹ýÉè¼Æ¸ü¶àµÄÓï·¨µÄÑÔÂÛ¡£ÏÖʵÖУ¬C++µÄ¿âÃÅÀà·±¶à£¬½â¾öµÄÎÊÌâÒ²ÊǼ«Æä¹ã·º£¬¿â´ÓÇáÁ¿¼¶µ½ÖØ
Á¿¼¶µÄ¶¼Ó ......
1. ö¾ÙµÄ¶¨Òåö¾ÙÀàÐͶ¨ÒåµÄÒ»°ãÐÎʽΪ£º
enum ö¾ÙÃû{ ö¾ÙÖµ±í };
ÔÚö¾ÙÖµ±íÖÐÓ¦ÂÞÁгöËùÓпÉÓÃÖµ¡£ÕâЩֵҲ³ÆΪö¾ÙÔªËØ¡£
ÀýÈ磺
¸Ãö¾ÙÃûΪweekday£¬Ã¶¾ÙÖµ¹²ÓÐ7¸ö£¬¼´Ò»ÖÜÖеÄÆßÌì¡£·²±»ËµÃ÷ΪweekdayÀàÐͱäÁ¿µÄÈ¡ÖµÖ»ÄÜÊÇÆßÌìÖеÄijһÌì¡£
2. ö¾Ù±äÁ¿µ ......