\u4e00\u4e9b\u4f8b\u5b50<\/strong><\/div>\n\u4e3a\u4e86\u66f4\u597d\u7684\u7406\u89e3\u4e0a\u8ff0\u5185\u5bb9\uff0c\u8fd9\u91cc\u6765\u4e3e\u4e00\u4e9b\u4f8b\u5b50\u3002\u5e38\u89c1\u7684\u4e00\u822c\u6709\u4e24\u79cd\u9009\u62e9\uff1a<\/p>\n
\u5e38\u6307\u9488\u6307\u5411\u4e00\u4e2a\u53d8\u91cf\uff0c\u9632\u6b62\u4fee\u6539\u6307\u9488\u4fee\u6539\u53d8\u91cf\u503c<\/p>\n
\u5e38\u6307\u9488\u6307\u5411\u4e00\u4e2a\u5e38\u91cf<\/p>\n
\u975e\u5e38\u6307\u9488\u6307\u5411\u5e38\u91cf\uff08\u9519\u8bef\uff09<\/p>\n
\u5148\u770b\u7b2c\u4e00\u79cd\u60c5\u51b5\uff1a\u89e3\u5f15\u7528\u53ea\u662f\u53d6\u51fa\u6307\u5411\u5185\u5b58\u533a\u57df\u7684\u503c\uff0c\u56e0\u6b64\u6307\u5411\u5185\u5b58\u533a\u57df\u7684\u503c\u662f\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\u7684\uff0c\u4f46\u4e0d\u80fd\u901a\u8fc7\u6307\u9488\u4fee\u6539\u3002<\/p>\n
\r\nint main (){\r\n int a{34};\r\n const int *p = &a;\r\n \/\/ *p \u4e3a const\uff0c\u4e0d\u80fd\u88ab\u4fee\u6539\r\n \/\/ \u9519\u8bef\r\n \/\/ *p ++;\r\n \/\/ p \u6307\u5411\u7684\u4e0d\u662f\u5e38\u91cf\uff0c\u56e0\u6b64\uff0c\u53ef\u4ee5\u4fee\u6539 a\r\n a ++;\r\n std::cout << *p << std::endl;\r\n \r\n int b{12};\r\n p = &b;\r\n std::cout << *p << std::endl;\r\n return 0;\r\n}<\/pre>\n\u5bf9\u4e8e\u7b2c\u4e8c\u79cd\u60c5\u51b5\uff1a\u4e0d\u80fd\u4fee\u6539\u53d8\u91cf\uff0c\u4e5f\u4e0d\u80fd\u4fee\u6539\u5e38\u91cf\u3002<\/p>\n
\r\nint main (){\r\n \r\n const int a{34};\r\n \/\/ *p \u4e3a const\uff0c\u4e0d\u80fd\u88ab\u4fee\u6539\uff0ca \u4e5f\u4e0d\u80fd\u88ab\u4fee\u6539\r\n const int *p = &a;\r\n std::cout << *p << std::endl;\r\n \r\n int b{12};\r\n p = &b;\r\n std::cout << *p << std::endl;\r\n \r\n return 0;\r\n}<\/pre>\n\u5bf9\u4e8e\u7b2c\u4e09\u79cd\u60c5\u51b5\uff1a\u4fee\u6539\u6307\u9488\u6765\u4fee\u6539\u5e38\u91cf\u4f1a\u663e\u5f97\u4f77\u8352\u8c2c\uff0c\u56e0\u6b64\u7f16\u8bd1\u4f1a\u76f4\u63a5\u62a5\u9519\uff1a<\/p>\n
\r\nint main (){\r\n const int a{34};\r\n \/\/ error: invalid conversion from 'const int*' to 'int*'\r\n int *p = &a;\r\n *p ++;\r\n std::cout << *p ;\r\n return 0;\r\n}<\/pre>\n\u4e8c\u7ea7\u6307\u9488<\/strong><\/div>\n\u4e4b\u524d\u8bf4\u5230\uff0c\u5e38\u6307\u9488\u53ef\u4ee5\u6307\u5411\u53d8\u91cf\uff0c\u4f46\u662f\u6d89\u53ca\u4e8c\u7ea7\u6307\u9488\u540e\uff0c\u60c5\u51b5\u53c8\u4f1a\u53d1\u751f\u9006\u8f6c\u3002<\/p>\n
\r\nint main (){\r\n \r\n const int a{12};\r\n const int** p1;\r\n int* p2;\r\n \r\n \/\/ error: invalid conversion from 'int**' to 'const int**'\r\n p1 = &p2;\r\n *p1 = &a;\r\n \r\n *p2 = 10;\r\n \r\n return 0;\r\n}<\/pre>\n\u5982\u679c\u4e0a\u8ff0\u4ee3\u7801\u901a\u8fc7\uff0c\u90a3\u4e48\u5b8c\u5168\u53ef\u4ee5\u901a\u8fc7 p2 \u6307\u9488\u4fee\u6539\u5e38\u91cf\u3002\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u4ee5\u4e0b\u7ed3\u8bba\uff1a<\/p>\n
\u82e5\u6570\u636e\u7c7b\u578b\u672c\u8eab\u4e0d\u662f\u6307\u9488\uff0c\u53ef\u4ee5\u5c06 const \u6570\u636e\u6216\u975e const \u6570\u636e\u7684\u5730\u5740\u8d4b\u7ed9\u6307\u5411 const \u7684\u6307\u9488\uff0c\u4f46\u6307\u9488\u53ef\u4ee5\u4fee\u6539\uff0c\u6307\u5411\u522b\u7684\u503c\u3002\u56e0\u6b64\uff0cconst \u4fee\u9970\u7684\u6570\u7ec4\u4e0d\u80fd\u4f20\u53c2\u7ed9\u975e\u5e38\u91cf\u6307\u9488\u3002<\/p>\n
\u5982\u679c\u6570\u636e\u7c7b\u578b\u662f\u6307\u9488\uff0c\u975e const \u6570\u636e\u7684\u5730\u5740\u53ea\u80fd\u8d4b\u503c\u7ed9\u975e const \u6307\u9488\uff0c\u5982\u4e8c\u7ea7\u6307\u9488\u4e2d\uff0cp1 = &p2 \u662f\u9519\u8bef\u7684\u3002<\/p>\n
\u603b\u7ed3<\/strong><\/div>\n\u5230\u6b64\u8fd9\u7bc7\u5173\u4e8eC++\u4e2d\u5e38\u91cf\u4e0e\u6307\u9488\u7684\u6587\u7ae0\u5c31\u4ecb\u7ecd\u5230\u8fd9\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u548c\u6307\u9488\u8054\u7528\u6709\u4f77\u5fae\u5999\u7684\u5730\u65b9\uff0c\u4e4b\u524d\u4e00\u76f4\u4f77\u6655\uff0c\u73b0\u5728\u6765\u7ee7\u7eed\u7814\u7a76\u4e0b\u3002\u8bf8\u5982\u4ee5\u4e0b\uff1a int const; const int […]<\/p>\n","protected":false},"author":1482,"featured_media":52821,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-221638","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1482"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=221638"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221638\/revisions"}],"predecessor-version":[{"id":221641,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221638\/revisions\/221641"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/52821"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=221638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=221638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=221638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}