{"rsdb":{"rid":"302564","subhead":"","postdate":"0","aid":"217735","fid":"49","uid":"1","topic":"1","content":"
\n

\u5e38\u91cf\uff1a<\/span><\/p> \n

\u5e38\u91cf\u7684\u5b9a\u4e49\u683c\u5f0f\uff1aconst datatype CONSTANTNAME = VALUE<\/p> \n

\u5e38\u91cf\u7684\u547d\u540d\u89c4\u8303\uff1a\u7b26\u53f7\u5e38\u91cf(\u5305\u62ec\u679a\u4e3e\u503c)\u5fc5\u987b\u5168\u90e8\u5927\u5199\u5e76\u7528\u4e0b\u5212\u7ebf\u5206\u9694\u5355\u8bcd \u4f8b\u5982\uff1aMAX_ITERATIONS, COLOR_RED, PI<\/p> \n

\u5e38\u91cf\u4e0e\u6307\u9488\uff1a<\/span><\/p> \n

two features of a pointer(\u6307\u9488\u7684\u4e24\u4e2a\u5c5e\u6027):<\/span><\/span><\/p> \n

? pointer variable (\u6307\u9488\u53d8\u91cf\u672c\u8eab)<\/span><\/span><\/p> \n

? data that the pointer points to (\u6307\u9488\u53d8\u91cf\u6240\u6307\u5411\u7684\u6570\u636e) <\/span><\/span><\/p> \n

\u5e38\u91cf\u548c\u6307\u9488\u7684\u7ec4\u5408\uff1a<\/span><\/p> \n

1.\u5e38\u91cf\u6307\u9488\/\u5e38\u6307\u9488\uff1a<\/span><\/span><\/p> \n

\u7279\u5f81\uff1a\u6307\u9488\u6240\u6307\u5411\u7684\u5185\u5bb9\u4e0d\u53ef\u4ee5\u901a\u8fc7\u6307\u9488\u7684\u95f4\u63a5\u5f15\u7528(*p)\u6765\u6539\u53d8\u3002<\/p> \n

\n
const<\/span> int<\/span>* p1; const<\/span> int<\/span> x = 1<\/span>;\r\n p1 <\/span>= &x;      \/\/<\/span> \u6307\u9488p1 \u7684 \u7c7b\u578b\u662f(const int*)<\/span>\r\n*p1 = 10<\/span>;     \/\/<\/span> Error!<\/span><\/pre> \n <\/div> \n 

2.\u6307\u9488\u5e38\u91cf\uff1a<\/span><\/span><\/p> \n

 \u7279\u5f81\uff1a\u6307\u9488\u672c\u8eab\u7684\u5185\u5bb9\u662f\u4e2a\u5e38\u91cf\uff0c\u4e0d\u53ef\u4ee5\u6539\u53d8\u3002<\/span><\/span><\/p> \n

\n
int<\/span> x = 1<\/span>, y = 1<\/span>; \r\n<\/span>int<\/span>* const<\/span> p2 = &x; \/\/<\/span> \u5e38\u91cfp2 \u7684 \u7c7b\u578b\u662f(int*)<\/span>\r\n*p2 = 10<\/span>;     \/\/<\/span> Okay! ?x=10<\/span>\r\np2 = &y; \/\/<\/span> Error! p2 is a constant<\/span><\/pre> \n <\/div> \n 

 <\/p>\n<\/div>","orderid":"0","title":"C++\u7a0b\u5e8f\u8bbe\u8ba1\u5165\u95e8 \u4e4b\u5e38\u91cf\u5b66\u4e60","smalltitle":"","mid":"0","fname":"c++\u7f16\u7a0b\u57fa\u7840","special_id":"0","bak_id":"0","info":"0","hits":"101","pages":"1","comments":"0","posttime":"2019-04-07 16:07:47","list":"1554624467","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u7a0b\u5e8f\u8bbe\u8ba1<\/A> \u5165\u95e8<\/A> \u5e38\u91cf<\/A> \u5b66\u4e60<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"47.106.78.186","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"C++\u7a0b\u5e8f\u8bbe\u8ba1\u5165\u95e8 \u4e4b\u5e38\u91cf\u5b66\u4e60","lastview":"1702385743","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}