{"id":68378,"date":"2026-01-30T03:57:09","date_gmt":"2026-01-29T19:57:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/68378.html"},"modified":"2026-01-30T03:57:09","modified_gmt":"2026-01-29T19:57:09","slug":"c-%e5%9f%ba%e7%a1%80%e6%a0%b8%e5%bf%83%e7%9f%a5%e8%af%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/68378.html","title":{"rendered":"C++ \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6"},"content":{"rendered":"<h2>C&#043;&#043; \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6<\/h2>\n<p>C&#043;&#043;\u4f5c\u4e3a\u4e00\u95e8\u517c\u5177\u9ad8\u6548\u6027\u548c\u7075\u6d3b\u6027\u7684\u7f16\u7a0b\u8bed\u8a00&#xff0c;\u662f\u7cfb\u7edf\u5f00\u53d1\u3001\u6e38\u620f\u5f15\u64ce\u3001\u5d4c\u5165\u5f0f\u7f16\u7a0b\u7b49\u9886\u57df\u7684\u6838\u5fc3\u5de5\u5177\u3002\u672c\u6587\u5c06\u4ece\u53d8\u91cf\u7c7b\u578b\u3001\u6307\u9488\u4e0e\u5f15\u7528\u3001\u6838\u5fc3\u5173\u952e\u5b57\u3001\u6570\u636e\u7c7b\u578b\u3001\u5b8f\u4e0e\u9ad8\u7ea7\u4fee\u9970\u7b26\u3001\u51fd\u6570\u6307\u9488\u7b49\u9ad8\u9891\u57fa\u7840\u77e5\u8bc6\u70b9\u5165\u624b&#xff0c;\u592f\u5b9e\u7f16\u7a0b\u57fa\u7840\u3002<\/p>\n<h3>\u4e00\u3001\u53d8\u91cf\u7684\u4e09\u7c7b\u6838\u5fc3\u5f62\u6001&#xff1a;\u5c40\u90e8\u3001\u9759\u6001\u5c40\u90e8\u3001\u5168\u5c40<\/h3>\n<p>\u53d8\u91cf\u662f\u7a0b\u5e8f\u5b58\u50a8\u6570\u636e\u7684\u57fa\u672c\u5355\u5143&#xff0c;\u6839\u636e\u4f5c\u7528\u57df\u3001\u751f\u547d\u5468\u671f\u548c\u5b58\u50a8\u4f4d\u7f6e\u7684\u5dee\u5f02&#xff0c;\u53ef\u5206\u4e3a\u5c40\u90e8\u53d8\u91cf\u3001\u9759\u6001\u5c40\u90e8\u53d8\u91cf\u548c\u5168\u5c40\u53d8\u91cf\u4e09\u7c7b&#xff0c;\u5176\u7279\u6027\u548c\u4f7f\u7528\u573a\u666f\u5404\u6709\u4fa7\u91cd&#xff0c;\u662f\u7406\u89e3C&#043;&#043;\u5185\u5b58\u7ba1\u7406\u7684\u57fa\u7840\u3002<\/p>\n<h4>1. \u6838\u5fc3\u7279\u6027\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u5206\u7c7b\u4f5c\u7528\u57df\u751f\u547d\u5468\u671f\u521d\u59cb\u5316\u884c\u4e3a\u5b58\u50a8\u4f4d\u7f6e\u6838\u5fc3\u7279\u70b9<\/tr>\n<tbody>\n<tr>\n<td>\u5c40\u90e8\u53d8\u91cf<\/td>\n<td>\u5f53\u524d\u51fd\u6570\/\u4ee3\u7801\u5757\u5185<\/td>\n<td>\u51fd\u6570\u8c03\u7528\u65f6\u521b\u5efa&#xff0c;\u8fd4\u56de\u65f6\u9500\u6bc1<\/td>\n<td>\u672a\u8d4b\u503c\u5219\u503c\u968f\u673a<\/td>\n<td>\u6808\u533a&#xff08;stack&#xff09;<\/td>\n<td>\u5b58\u53d6\u901f\u5ea6\u5feb&#xff0c;\u968f\u7528\u968f\u5f03&#xff0c;\u65e0\u5185\u5b58\u6cc4\u6f0f\u98ce\u9669<\/td>\n<\/tr>\n<tr>\n<td>\u9759\u6001\u5c40\u90e8\u53d8\u91cf<\/td>\n<td>\u5f53\u524d\u51fd\u6570\u5185\u90e8&#xff08;\u5916\u90e8\u4e0d\u53ef\u8bbf\u95ee&#xff09;<\/td>\n<td>\u7a0b\u5e8f\u542f\u52a8\u81f3\u7ed3\u675f<\/td>\n<td>\u4ec5\u521d\u59cb\u5316\u4e00\u6b21&#xff0c;\u9ed8\u8ba4\u503c0<\/td>\n<td>\u6570\u636e\u6bb5\/BSS\u6bb5<\/td>\n<td>\u4fdd\u7559\u4e0a\u6b21\u8c03\u7528\u7ed3\u679c&#xff0c;\u51fd\u6570\u5185\u7684\u201c\u5168\u5c40\u72b6\u6001\u201d<\/td>\n<\/tr>\n<tr>\n<td>\u5168\u5c40\u53d8\u91cf<\/td>\n<td>\u6574\u4e2a\u7a0b\u5e8f\u5185<\/td>\n<td>\u7a0b\u5e8f\u542f\u52a8\u81f3\u7ed3\u675f<\/td>\n<td>\u9ed8\u8ba4\u521d\u59cb\u5316\u4e3a0<\/td>\n<td>\u6570\u636e\u6bb5\/BSS\u6bb5<\/td>\n<td>\u8de8\u51fd\u6570\/\u6587\u4ef6\u5171\u4eab&#xff0c;\u6613\u5bfc\u81f4\u7a0b\u5e8f\u8026\u5408\u5ea6\u5347\u9ad8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2. \u5b9e\u7528\u573a\u666f\u89e3\u6790<\/h4>\n<ul>\n<li>\u5c40\u90e8\u53d8\u91cf&#xff1a;\u6700\u5e38\u7528\u7684\u53d8\u91cf\u7c7b\u578b&#xff0c;\u9002\u5408\u5b58\u50a8\u4e34\u65f6\u6570\u636e&#xff0c;\u6bd4\u5982\u5faa\u73af\u8ba1\u6570\u5668\u3001\u51fd\u6570\u5185\u90e8\u7684\u4e2d\u95f4\u8ba1\u7b97\u7ed3\u679c\u3002\u4f8b\u5982\u904d\u5386\u6570\u7ec4\u65f6\u7684\u7d22\u5f15\u53d8\u91cfint i&#xff0c;\u51fd\u6570\u5185\u4e34\u65f6\u5b58\u50a8\u8ba1\u7b97\u503c\u7684int temp&#xff0c;\u7528\u5b8c\u81ea\u52a8\u91ca\u653e\u6808\u5185\u5b58&#xff0c;\u4f7f\u7528\u5b89\u5168\u4e14\u65e0\u5197\u4f59\u5f00\u9500\u3002<\/li>\n<li>\u9759\u6001\u5c40\u90e8\u53d8\u91cf&#xff1a;\u9002\u5408\u9700\u8981\u201c\u8bb0\u5fc6\u72b6\u6001\u201d\u7684\u573a\u666f&#xff0c;\u6bd4\u5982\u7edf\u8ba1\u51fd\u6570\u8c03\u7528\u6b21\u6570\u3001\u9012\u5f52\u6df1\u5ea6\u63a7\u5236\u3001\u5355\u4f8b\u6a21\u5f0f\u7684\u61d2\u6c49\u5f0f\u5b9e\u73b0\u3002\u4f8b\u5982&#xff1a;<\/li>\n<\/ul>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">countCall<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">int<\/span> count <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u4ec5\u9996\u6b21\u8c03\u7528\u521d\u59cb\u5316&#xff0c;\u540e\u7eed\u8c03\u7528\u4fdd\u7559\u503c<\/span><br \/>\n    cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;\u8c03\u7528\u6b21\u6570&#xff1a;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token operator\">&#043;&#043;<\/span>count <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\">\/\/ \u591a\u6b21\u8c03\u7528\u4f9d\u6b21\u8f93\u51fa1\u30012\u30013&#8230;<\/span><\/p>\n<ul>\n<li>\u5168\u5c40\u53d8\u91cf&#xff1a;\u7528\u4e8e\u5b58\u50a8\u6574\u4e2a\u7a0b\u5e8f\u9700\u5171\u4eab\u7684\u5168\u5c40\u6570\u636e&#xff0c;\u6bd4\u5982\u7cfb\u7edf\u914d\u7f6e\u4fe1\u606f\u3001\u5168\u5c40\u7f13\u51b2\u533a\u3001\u8de8\u6a21\u5757\u7684\u72b6\u6001\u6807\u8bc6\u3002\u4f46\u9700\u8c28\u614e\u4f7f\u7528&#xff0c;\u8fc7\u591a\u5168\u5c40\u53d8\u91cf\u4f1a\u5bfc\u81f4\u7a0b\u5e8f\u8026\u5408\u5ea6\u5347\u9ad8\u3001\u96be\u4ee5\u7ef4\u62a4\u548c\u8c03\u8bd5&#xff1b;\u4f7f\u7528\u65f6\u53ef\u6dfb\u52a0\u6e05\u6670\u6ce8\u91ca&#xff0c;\u5fc5\u8981\u65f6\u7528static\u4fee\u9970\u9650\u5236\u5728\u5f53\u524d\u6587\u4ef6\u5185&#xff0c;\u907f\u514d\u8de8\u6587\u4ef6\u547d\u540d\u51b2\u7a81\u3002<\/li>\n<\/ul>\n<h3>\u4e8c\u3001\u6307\u9488\u4e0e\u5f15\u7528&#xff1a;C&#043;&#043;\u7684\u6838\u5fc3\u5185\u5b58\u64cd\u4f5c\u7b26<\/h3>\n<p>\u6307\u9488\u548c\u5f15\u7528\u662fC&#043;&#043;\u533a\u522b\u4e8e\u5176\u4ed6\u9ad8\u7ea7\u8bed\u8a00\u7684\u6838\u5fc3\u7279\u6027&#xff0c;\u4e8c\u8005\u5747\u7528\u4e8e\u95f4\u63a5\u64cd\u4f5c\u53d8\u91cf&#xff0c;\u5b9e\u73b0\u5185\u5b58\u7684\u7075\u6d3b\u8bbf\u95ee&#xff0c;\u4f46\u5728\u8bed\u6cd5\u3001\u672c\u8d28\u3001\u529f\u80fd\u548c\u4f7f\u7528\u573a\u666f\u4e0a\u5dee\u5f02\u663e\u8457&#xff0c;\u6b63\u786e\u533a\u5206\u662f\u907f\u514d\u5185\u5b58\u9519\u8bef\u7684\u5173\u952e\u3002<\/p>\n<h4>1. \u6838\u5fc3\u533a\u522b\u603b\u7ed3<\/h4>\n<table>\n<tr>\u7279\u6027\u6307\u9488\u5f15\u7528<\/tr>\n<tbody>\n<tr>\n<td>\u672c\u8d28<\/td>\n<td>\u5b58\u50a8\u53d8\u91cf\u5185\u5b58\u5730\u5740\u7684\u72ec\u7acb\u53d8\u91cf&#xff0c;\u6709\u81ea\u5df1\u7684\u5185\u5b58\u7a7a\u95f4<\/td>\n<td>\u53d8\u91cf\u7684\u522b\u540d&#xff0c;\u65e0\u72ec\u7acb\u5185\u5b58\u7a7a\u95f4&#xff0c;\u4e0e\u7ed1\u5b9a\u5bf9\u8c61\u5171\u4eab\u5730\u5740<\/td>\n<\/tr>\n<tr>\n<td>\u521d\u59cb\u5316<\/td>\n<td>\u53ef\u5ef6\u8fdf\u521d\u59cb\u5316&#xff0c;\u53ef\u8bbe\u4e3anullptr&#xff08;\u7a7a\u6307\u9488&#xff09;<\/td>\n<td>\u5fc5\u987b\u5728\u5b9a\u4e49\u65f6\u521d\u59cb\u5316&#xff0c;\u4e14\u4e0d\u80fd\u7ed1\u5b9a\u7a7a\u503c\/\u65e0\u6548\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>\u91cd\u65b0\u7ed1\u5b9a<\/td>\n<td>\u53ef\u968f\u65f6\u91cd\u65b0\u6307\u5411\u5176\u4ed6\u540c\u7c7b\u578b\u5bf9\u8c61<\/td>\n<td>\u4e00\u65e6\u7ed1\u5b9a\u5bf9\u8c61&#xff0c;\u751f\u547d\u5468\u671f\u5185\u4e0d\u53ef\u4fee\u6539\u7ed1\u5b9a\u5173\u7cfb<\/td>\n<\/tr>\n<tr>\n<td>\u64cd\u4f5c\u65b9\u5f0f<\/td>\n<td>\u9700\u901a\u8fc7\u89e3\u5f15\u7528\u7b26&#xff08;*&#xff09;\u8bbf\u95ee\u76ee\u6807\u503c&#xff0c;\u6307\u9488\u79fb\u52a8\u7528-&gt;<\/td>\n<td>\u76f4\u63a5\u64cd\u4f5c&#xff0c;\u65e0\u9700\u89e3\u5f15\u7528&#xff0c;\u8bed\u6cd5\u4e0e\u666e\u901a\u53d8\u91cf\u4e00\u81f4<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5360\u7528<\/td>\n<td>32\u4f4d\u7cfb\u7edf4\u5b57\u8282&#xff0c;64\u4f4d\u7cfb\u7edf8\u5b57\u8282&#xff08;\u4e0e\u5730\u5740\u957f\u5ea6\u4e00\u81f4&#xff09;<\/td>\n<td>\u65e0\u989d\u5916\u5185\u5b58\u5360\u7528&#xff0c;\u7f16\u8bd1\u671f\u5904\u7406&#xff0c;\u4e0e\u7ed1\u5b9a\u5bf9\u8c61\u5927\u5c0f\u4e00\u81f4<\/td>\n<\/tr>\n<tr>\n<td>\u5b89\u5168\u6027<\/td>\n<td>\u53ef\u80fd\u51fa\u73b0\u91ce\u6307\u9488\/\u60ac\u7a7a\u6307\u9488&#xff0c;\u4f7f\u7528\u524d\u5fc5\u987b\u5224\u7a7a<\/td>\n<td>\u65e0\u7a7a\u5f15\u7528&#xff0c;\u53ea\u8981\u7ed1\u5b9a\u6709\u6548\u5bf9\u8c61\u5219\u4f7f\u7528\u5b89\u5168&#xff0c;\u65e0\u9700\u5224\u7a7a<\/td>\n<\/tr>\n<tr>\n<td>\u652f\u6301\u64cd\u4f5c<\/td>\n<td>\u53ef\u8fdb\u884c\u6307\u9488\u7b97\u672f\u8fd0\u7b97&#xff08;\u5982p&#043;&#043;&#xff09;\u3001\u591a\u7ea7\u6307\u9488&#xff08;int**&#xff09;<\/td>\n<td>\u4e0d\u652f\u6301\u7b97\u672f\u8fd0\u7b97&#xff0c;\u65e0\u591a\u7ea7\u5f15\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2. \u9002\u7528\u573a\u666f<\/h4>\n<ul>\n<li>\n<p>\u6307\u9488\u7684\u9002\u7528\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\u52a8\u6001\u5185\u5b58\u5206\u914d&#xff08;new\/delete&#xff09;&#xff1a;\u4f8b\u5982\u521b\u5efa\u52a8\u6001\u6570\u7ec4int* arr &#061; new int[10]\u3001\u81ea\u5b9a\u4e49\u7c7b\u7684\u52a8\u6001\u5bf9\u8c61&#xff1b;<\/li>\n<li>\u904d\u5386\u590d\u6742\u6570\u636e\u7ed3\u6784&#xff08;\u94fe\u8868\u3001\u6811\u3001\u56fe&#xff09;&#xff1a;\u901a\u8fc7\u6307\u9488\u79fb\u52a8\u8bbf\u95ee\u4e0b\u4e00\u4e2a\u8282\u70b9node-&gt;next&#xff0c;\u5b9e\u73b0\u7075\u6d3b\u7684\u5185\u5b58\u904d\u5386&#xff1b;<\/li>\n<li>\u5904\u7406\u53ef\u9009\u53c2\u6570&#xff1a;\u5141\u8bb8\u4f20\u9012nullptr\u8868\u793a\u201c\u65e0\u53c2\u6570\u201d&#xff0c;\u9002\u914d\u591a\u573a\u666f\u51fd\u6570\u8c03\u7528&#xff1b;<\/li>\n<li>\u591a\u7ea7\u95f4\u63a5\u8bbf\u95ee&#xff1a;\u5982\u6307\u9488\u7684\u6307\u9488int** p&#xff0c;\u9002\u7528\u4e8e\u4e8c\u7ef4\u6570\u7ec4\u3001\u51fd\u6570\u5185\u4fee\u6539\u5916\u90e8\u6307\u9488&#xff1b;<\/li>\n<li>\u51fd\u6570\u8fd4\u56de\u591a\u4e2a\u503c&#xff1a;\u901a\u8fc7\u6307\u9488\u5c06\u7ed3\u679c\u8f93\u51fa\u5230\u51fd\u6570\u5916\u90e8\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5f15\u7528\u7684\u9002\u7528\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\u51fd\u6570\u53c2\u6570\u4f20\u9012&#xff1a;\u5c24\u5176\u662f\u5927\u578b\u5bf9\u8c61&#xff08;\u5982\u81ea\u5b9a\u4e49\u7c7b\u5b9e\u4f8b\u3001std::string\u3001std::vector&#xff09;&#xff0c;\u907f\u514d\u62f7\u8d1d\u5f00\u9500&#xff0c;\u63d0\u5347\u7a0b\u5e8f\u6548\u7387\u3002\u4f8b\u5982void printString(const string&amp; s)&#xff0c;\u76f4\u63a5\u5f15\u7528\u539f\u5bf9\u8c61\u800c\u975e\u521b\u5efa\u62f7\u8d1d&#xff1b;<\/li>\n<li>\u51fd\u6570\u8fd4\u56de\u503c\u4f18\u5316&#xff1a;\u5b9e\u73b0\u94fe\u5f0f\u8c03\u7528&#xff08;\u5982cout &lt;&lt; a &lt;&lt; b&#xff0c;operator&lt;&lt;\u8fd4\u56deostream&amp;&#xff09;&#xff0c;\u907f\u514d\u8fd4\u56de\u503c\u62f7\u8d1d&#xff1b;<\/li>\n<li>\u7c7b\u6210\u5458\u5f15\u7528&#xff1a;\u5fc5\u987b\u5728\u6784\u9020\u51fd\u6570\u521d\u59cb\u5316\u5217\u8868\u4e2d\u7ed1\u5b9a&#xff0c;\u786e\u4fdd\u5f15\u7528\u7684\u751f\u547d\u5468\u671f\u4e0e\u7c7b\u5bf9\u8c61\u4e00\u81f4&#xff0c;\u9002\u7528\u4e8e\u7c7b\u7684\u5173\u8054\u5c5e\u6027&#xff1b;<\/li>\n<li>\u66ff\u4ee3\u6307\u9488\u7b80\u5316\u4ee3\u7801&#xff1a;\u5728\u65e0\u9700\u91cd\u65b0\u7ed1\u5b9a\u7684\u573a\u666f\u4e0b&#xff0c;\u7528\u5f15\u7528\u66ff\u4ee3\u6307\u9488&#xff0c;\u8ba9\u4ee3\u7801\u66f4\u7b80\u6d01\u3001\u5b89\u5168\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>3. \u6838\u5fc3\u6ce8\u610f\u4e8b\u9879<\/h4>\n<ul>\n<li>\u6307\u9488\u4f7f\u7528\u524d\u5fc5\u987b\u5224\u7a7a&#xff08;if (p !&#061; nullptr)&#xff09;&#xff0c;\u907f\u514d\u91ce\u6307\u9488&#xff08;\u672a\u521d\u59cb\u5316&#xff09;\u3001\u60ac\u7a7a\u6307\u9488&#xff08;\u6307\u5411\u5df2\u91ca\u653e\u5185\u5b58&#xff09;\u5bfc\u81f4\u7a0b\u5e8f\u5d29\u6e83&#xff1b;<\/li>\n<li>\u5f15\u7528\u4e0d\u80fd\u7ed1\u5b9a\u4e34\u65f6\u53d8\u91cf&#xff08;\u5982int&amp; a &#061; 10;\u975e\u6cd5&#xff09;&#xff0c;\u9664\u975e\u662fconst\u5f15\u7528&#xff08;const int&amp; a &#061; 10;\u5408\u6cd5&#xff0c;\u7f16\u8bd1\u5668\u4f1a\u521b\u5efa\u4e34\u65f6\u5bf9\u8c61&#xff09;&#xff1b;<\/li>\n<li>\u52a8\u6001\u5185\u5b58\u5206\u914d\u7684\u6307\u9488\u9700\u624b\u52a8\u91ca\u653e&#xff08;delete\/delete[]&#xff09;&#xff0c;\u5426\u5219\u4f1a\u9020\u6210\u5185\u5b58\u6cc4\u6f0f&#xff1b;\u5efa\u8bae\u4f18\u5148\u4f7f\u7528\u667a\u80fd\u6307\u9488&#xff08;std::unique_ptr\/std::shared_ptr&#xff09;\u66ff\u4ee3\u88f8\u6307\u9488\u3002<\/li>\n<\/ul>\n<h3>\u4e09\u3001\u6838\u5fc3\u5173\u952e\u5b57<\/h3>\n<p>C&#043;&#043;\u7684\u5173\u952e\u5b57\u662f\u63a7\u5236\u7a0b\u5e8f\u8bed\u6cd5\u89c4\u5219\u3001\u5185\u5b58\u884c\u4e3a\u3001\u8bbf\u95ee\u6743\u9650\u7684\u6838\u5fc3&#xff0c;\u5176\u4e2dconst\u3001static\u662f\u6700\u5e38\u7528\u4e14\u6613\u6df7\u6dc6\u7684\u57fa\u7840\u5173\u952e\u5b57&#xff0c;\u638c\u63e1\u5176\u4e0d\u540c\u573a\u666f\u7684\u8bed\u4e49&#xff0c;\u662f\u7f16\u5199\u89c4\u8303\u3001\u9ad8\u6548C&#043;&#043;\u4ee3\u7801\u7684\u524d\u63d0\u3002<\/p>\n<h4>1. const&#xff1a;\u5e38\u91cf\u4fee\u9970\u7b26&#xff0c;\u4fdd\u8bc1\u53ea\u8bfb\u7279\u6027<\/h4>\n<p>const\u7684\u6838\u5fc3\u8bed\u4e49\u662f\u53ea\u8bfb&#xff0c;\u53ef\u4fee\u9970\u53d8\u91cf\u3001\u6307\u9488\u3001\u5f15\u7528\u3001\u6210\u5458\u51fd\u6570\u3001\u51fd\u6570\u53c2\u6570\u7b49&#xff0c;\u662f\u4fdd\u8bc1\u7a0b\u5e8f\u5b89\u5168\u6027\u3001\u9632\u6b62\u610f\u5916\u4fee\u6539\u7684\u91cd\u8981\u5de5\u5177&#xff0c;\u5176\u4fee\u9970\u5bf9\u8c61\u4e0d\u540c&#xff0c;\u8bed\u4e49\u4e5f\u7565\u6709\u5dee\u5f02\u3002<\/p>\n<ul>\n<li>\u4fee\u9970\u666e\u901a\u53d8\u91cf&#xff1a;const int max &#061; 100&#xff0c;\u53d8\u91cf\u503c\u521d\u59cb\u5316\u540e\u4e0d\u53ef\u4fee\u6539&#xff0c;\u5fc5\u987b\u5728\u5b9a\u4e49\u65f6\u521d\u59cb\u5316&#xff1b;<\/li>\n<li>\u4fee\u9970\u6307\u9488&#xff1a;\u5206\u4e3a\u4e24\u79cd\u573a\u666f&#xff0c;\u6838\u5fc3\u770bconst\u4e0e*\u7684\u4f4d\u7f6e&#xff1a;\n<ul>\n<li>\u6307\u9488\u5e38\u91cf&#xff08;int* const p&#xff09;&#xff1a;const\u4fee\u9970\u6307\u9488\u672c\u8eab&#xff0c;\u6307\u9488\u7684\u6307\u5411\u4e0d\u53ef\u4fee\u6539&#xff0c;\u4f46\u6307\u5411\u7684\u503c\u53ef\u4fee\u6539&#xff1b;<\/li>\n<li>\u6307\u5411\u5e38\u91cf\u7684\u6307\u9488&#xff08;const int* p&#xff09;&#xff1a;const\u4fee\u9970\u6307\u5411\u7684\u503c&#xff0c;\u503c\u4e0d\u53ef\u4fee\u6539&#xff0c;\u4f46\u6307\u9488\u7684\u6307\u5411\u53ef\u4fee\u6539&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\u4fee\u9970\u5f15\u7528&#xff1a;const int&amp; ref&#xff0c;\u5f15\u7528\u7684\u5bf9\u8c61\u4e3a\u53ea\u8bfb&#xff0c;\u9632\u6b62\u901a\u8fc7\u5f15\u7528\u4fee\u6539\u539f\u5bf9\u8c61&#xff0c;\u662f\u51fd\u6570\u53c2\u6570\u4f20\u9012\u7684\u5e38\u7528\u65b9\u5f0f&#xff1b;<\/li>\n<li>\u4fee\u9970\u7c7b\u6210\u5458\u51fd\u6570&#xff1a;void show() const&#xff0c;\u51fd\u6570\u540e\u52a0const&#xff0c;\u8868\u793a\u8be5\u51fd\u6570\u4e0d\u4fee\u6539\u7c7b\u7684\u4efb\u4f55\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff0c;\u662f\u7c7b\u7684\u5e38\u6210\u5458\u51fd\u6570&#xff1b;<\/li>\n<li>\u4fee\u9970\u51fd\u6570\u53c2\u6570&#xff1a;void func(const int&amp; x)&#xff0c;\u9632\u6b62\u51fd\u6570\u5185\u90e8\u4fee\u6539\u4f20\u5165\u7684\u53c2\u6570\u503c&#xff0c;\u540c\u65f6\u907f\u514d\u62f7\u8d1d\u5f00\u9500\u3002<\/li>\n<\/ul>\n<h4>2. static&#xff1a;\u9759\u6001\u4fee\u9970\u7b26&#xff0c;\u63a7\u5236\u751f\u547d\u5468\u671f\u4e0e\u4f5c\u7528\u57df<\/h4>\n<p>static\u4e3b\u8981\u7528\u4e8e\u63a7\u5236\u53d8\u91cf\/\u51fd\u6570\u7684\u751f\u547d\u5468\u671f\u3001\u4f5c\u7528\u57df\u548c\u8bbf\u95ee\u6743\u9650&#xff0c;\u5728\u4e0d\u540c\u573a\u666f\u4e0b\u4f5c\u7528\u4e0d\u540c&#xff0c;\u6838\u5fc3\u5206\u4e3a\u201c\u5168\u5c40\/\u51fd\u6570\u5185\u201d\u548c\u201c\u7c7b\u5185\u201d\u4e24\u5927\u4f7f\u7528\u573a\u666f\u3002<\/p>\n<ul>\n<li>\u9759\u6001\u5c40\u90e8\u53d8\u91cf&#xff08;\u51fd\u6570\u5185&#xff09;&#xff1a;\u5ef6\u957f\u751f\u547d\u5468\u671f\u81f3\u7a0b\u5e8f\u7ed3\u675f&#xff0c;\u4f5c\u7528\u57df\u4ecd\u9650\u4e8e\u5f53\u524d\u51fd\u6570\u5185&#xff0c;\u4ec5\u521d\u59cb\u5316\u4e00\u6b21&#xff1b;<\/li>\n<li>\u9759\u6001\u5168\u5c40\u53d8\u91cf\/\u51fd\u6570&#xff08;\u6587\u4ef6\u5185&#xff09;&#xff1a;\u5c06\u4f5c\u7528\u57df\u9650\u5236\u5728\u5f53\u524d\u6587\u4ef6\u5185&#xff0c;\u5b9e\u73b0\u201c\u6587\u4ef6\u79c1\u6709\u201d&#xff0c;\u907f\u514d\u8de8\u6587\u4ef6\u547d\u540d\u51b2\u7a81&#xff1b;\u51fd\u6570\u9ed8\u8ba4\u5177\u6709\u5916\u90e8\u94fe\u63a5\u5c5e\u6027&#xff0c;\u52a0static\u540e\u53d8\u4e3a\u5185\u90e8\u94fe\u63a5&#xff1b;<\/li>\n<li>\u7c7b\u7684\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u5c5e\u4e8e\u7c7b\u800c\u975e\u67d0\u4e2a\u5bf9\u8c61&#xff0c;\u6240\u6709\u7c7b\u5b9e\u4f8b\u5171\u4eab\u540c\u4e00\u4efd\u6570\u636e&#xff0c;\u9700\u5728\u7c7b\u5916\u5355\u72ec\u521d\u59cb\u5316&#xff08;int ClassName::var &#061; 0&#xff09;&#xff0c;\u5b58\u50a8\u5728\u6570\u636e\u6bb5&#xff1b;<\/li>\n<li>\u7c7b\u7684\u9759\u6001\u6210\u5458\u51fd\u6570&#xff1a;\u5c5e\u4e8e\u7c7b\u800c\u975e\u5bf9\u8c61&#xff0c;\u65e0\u9690\u5f0f\u7684this\u6307\u9488&#xff0c;\u53ea\u80fd\u8bbf\u95ee\u7c7b\u7684\u9759\u6001\u6210\u5458&#xff08;\u53d8\u91cf\/\u51fd\u6570&#xff09;&#xff0c;\u53ef\u901a\u8fc7\u7c7b\u540d\u76f4\u63a5\u8c03\u7528&#xff08;ClassName::func()&#xff09;&#xff0c;\u65e0\u9700\u521b\u5efa\u5bf9\u8c61\u3002<\/li>\n<\/ul>\n<h4>3. new\/delete \u4e0e malloc\/free&#xff1a;\u5185\u5b58\u7ba1\u7406\u6838\u5fc3\u5bf9\u6bd4<\/h4>\n<p>new\/delete\u662fC&#043;&#043;\u539f\u751f\u7684\u5185\u5b58\u64cd\u4f5c\u8fd0\u7b97\u7b26&#xff0c;malloc\/free\u662fC\u6807\u51c6\u5e93\u7684\u5185\u5b58\u7ba1\u7406\u51fd\u6570&#xff0c;\u4e8c\u8005\u5747\u7528\u4e8e\u52a8\u6001\u5185\u5b58\u5206\u914d&#xff0c;\u4f46\u5728\u8bed\u6cd5\u3001\u529f\u80fd\u3001\u7279\u6027\u4e0a\u5dee\u5f02\u663e\u8457&#xff0c;C&#043;&#043;\u5f00\u53d1\u4e2d\u4f18\u5148\u4f7f\u7528new\/delete\u66ff\u4ee3malloc\/free\u3002<\/p>\n<table>\n<tr>\u7279\u6027new\/deletemalloc\/free<\/tr>\n<tbody>\n<tr>\n<td>\u672c\u8d28<\/td>\n<td>C&#043;&#043;\u8bed\u8a00\u539f\u751f\u8fd0\u7b97\u7b26&#xff0c;\u5c5e\u4e8e\u8bed\u6cd5\u5c42\u9762<\/td>\n<td>C\u6807\u51c6\u5e93\u666e\u901a\u51fd\u6570&#xff0c;\u9700\u5f15\u5165\u5934\u6587\u4ef6&lt;cstdlib&gt;<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u8ba1\u7b97<\/td>\n<td>\u81ea\u52a8\u8ba1\u7b97\u6240\u9700\u5185\u5b58\u5927\u5c0f&#xff0c;\u65e0\u9700\u624b\u52a8\u6307\u5b9a<\/td>\n<td>\u9700\u5f00\u53d1\u8005\u624b\u52a8\u8ba1\u7b97\u5e76\u4f20\u5165\u5185\u5b58\u5b57\u8282\u6570&#xff08;\u5982malloc(4*10)&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u521d\u59cb\u5316\/\u6790\u6784<\/td>\n<td>new\u8c03\u7528\u5bf9\u8c61\u6784\u9020\u51fd\u6570\u5b8c\u6210\u521d\u59cb\u5316&#xff0c;delete\u8c03\u7528\u6790\u6784\u51fd\u6570\u91ca\u653e\u8d44\u6e90<\/td>\n<td>\u4ec5\u5206\u914d\/\u91ca\u653e\u539f\u59cb\u5185\u5b58&#xff0c;\u4e0d\u8c03\u7528\u6784\u9020\/\u6790\u6784\u51fd\u6570&#xff0c;\u5185\u5b58\u5185\u5bb9\u4e3a\u968f\u673a\u503c<\/td>\n<\/tr>\n<tr>\n<td>\u8fd4\u56de\u503c\u7c7b\u578b<\/td>\n<td>\u5e26\u7c7b\u578b\u7684\u6307\u9488&#xff0c;\u65e0\u9700\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362&#xff08;\u5982int* p &#061; new int&#xff09;<\/td>\n<td>\u8fd4\u56devoid*\u7c7b\u578b\u6307\u9488&#xff0c;\u5fc5\u987b\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u540e\u4f7f\u7528&#xff08;\u5982int* p &#061; (int*)malloc(4)&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5931\u8d25\u5904\u7406<\/td>\n<td>\u5206\u914d\u5931\u8d25\u65f6\u629b\u51fabad_alloc\u5f02\u5e38&#xff0c;\u53ef\u901a\u8fc7try-catch\u6355\u83b7<\/td>\n<td>\u5206\u914d\u5931\u8d25\u65f6\u8fd4\u56deNULL&#xff0c;\u9700\u624b\u52a8\u5224\u7a7a\u68c0\u67e5<\/td>\n<\/tr>\n<tr>\n<td>\u91cd\u8f7d\u652f\u6301<\/td>\n<td>\u53ef\u81ea\u5b9a\u4e49\u91cd\u8f7d&#xff0c;\u5b9e\u73b0\u81ea\u5b9a\u4e49\u5185\u5b58\u6c60\u3001\u5185\u5b58\u5206\u914d\u7b56\u7565<\/td>\n<td>\u4e0d\u53ef\u91cd\u8f7d&#xff0c;\u5206\u914d\u7b56\u7565\u56fa\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u7ec4\u5904\u7406<\/td>\n<td>\u6709\u4e13\u95e8\u7684\u6570\u7ec4\u7248\u672cnew[]\/delete[]&#xff0c;\u5339\u914d\u6570\u7ec4\u7684\u6784\u9020\/\u6790\u6784<\/td>\n<td>\u65e0\u4e13\u95e8\u6570\u7ec4\u7248\u672c&#xff0c;\u9700\u624b\u52a8\u8ba1\u7b97\u6570\u7ec4\u603b\u5b57\u8282\u6570&#xff0c;\u4e14\u4e0d\u5904\u7406\u6570\u7ec4\u5bf9\u8c61\u7684\u6790\u6784<\/td>\n<\/tr>\n<tr>\n<td>\u7c7b\u5bf9\u8c61\u652f\u6301<\/td>\n<td>\u5b8c\u7f8e\u652f\u6301\u7c7b\u5bf9\u8c61\u7684\u52a8\u6001\u521b\u5efa\/\u91ca\u653e&#xff0c;\u662fC&#043;&#043;\u9762\u5411\u5bf9\u8c61\u7684\u6838\u5fc3\u652f\u6491<\/td>\n<td>\u4ec5\u80fd\u5206\u914d\u7c7b\u5bf9\u8c61\u7684\u5185\u5b58\u7a7a\u95f4&#xff0c;\u65e0\u6cd5\u521d\u59cb\u5316\u5bf9\u8c61&#xff0c;\u4e0d\u652f\u6301\u9762\u5411\u5bf9\u8c61\u5f00\u53d1<\/td>\n<\/tr>\n<tr>\n<td>\u793a\u4f8b<\/td>\n<td>\u5355\u4e2a\u5bf9\u8c61&#xff1a;int* p &#061; new int(10); delete p;\u6570\u7ec4&#xff1a;int* arr &#061; new int[5]; delete[] arr;\u7c7b\u5bf9\u8c61&#xff1a;Test* t &#061; new Test(); delete t;<\/td>\n<td>\u5355\u4e2a\u53d8\u91cf&#xff1a;int* p &#061; (int*)malloc(4); free(p);\u6570\u7ec4&#xff1a;int* arr &#061; (int*)malloc(4*5); free(arr);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4. \u5176\u4ed6\u57fa\u7840\u5e38\u7528\u5173\u952e\u5b57\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u5173\u952e\u5b57\/\u8bed\u6cd5\u672c\u8d28\u7279\u6027\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>typedef<\/td>\n<td>\u7f16\u8bd1\u9636\u6bb5\u7684\u7c7b\u578b\u522b\u540d\u5b9a\u4e49<\/td>\n<td>\u6709\u7c7b\u578b\u68c0\u67e5&#xff0c;\u63d0\u5347\u4ee3\u7801\u53ef\u8bfb\u6027&#xff0c;\u652f\u6301\u81ea\u5b9a\u4e49\u590d\u6742\u7c7b\u578b<\/td>\n<td>typedef int MyInt;  typedef vector&lt;int&gt; IntVec;<\/td>\n<\/tr>\n<tr>\n<td>nullptr<\/td>\n<td>C&#043;&#043;11\u7a7a\u6307\u9488\u5173\u952e\u5b57<\/td>\n<td>\u7c7b\u578b\u5b89\u5168&#xff0c;\u4ec5\u80fd\u9690\u5f0f\u8f6c\u6362\u4e3a\u6307\u9488\u7c7b\u578b&#xff0c;\u65e0\u4e8c\u4e49\u6027<\/td>\n<td>int* p &#061; nullptr;<\/td>\n<\/tr>\n<tr>\n<td>NULL<\/td>\n<td>\u5b8f\u5b9a\u4e49&#xff08;\u901a\u5e38\u4e3a0\u6216(void*)0&#xff09;<\/td>\n<td>\u53ef\u8f6c\u6362\u4e3a\u6574\u6570\u7c7b\u578b&#xff0c;\u53ef\u80fd\u5f15\u53d1\u51fd\u6570\u8c03\u7528\u4e8c\u4e49\u6027<\/td>\n<td>int* p &#061; NULL;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f7f\u7528\u5efa\u8bae&#xff1a;C&#043;&#043;\u5f00\u53d1\u4e2d\u4f18\u5148\u4f7f\u7528new\/delete\u66ff\u4ee3malloc\/free&#xff0c;\u4f18\u5148\u4f7f\u7528nullptr\u66ff\u4ee3NULL&#xff0c;\u907f\u514d\u7c7b\u578b\u4e8c\u4e49\u6027\u548c\u5185\u5b58\u7ba1\u7406\u9519\u8bef\u3002<\/p>\n<h3>\u56db\u3001\u6570\u636e\u7c7b\u578b\u4e0e\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362<\/h3>\n<p>C&#043;&#043;\u662f\u5f3a\u7c7b\u578b\u8bed\u8a00&#xff0c;\u6570\u636e\u7c7b\u578b\u51b3\u5b9a\u4e86\u53d8\u91cf\u7684\u5185\u5b58\u5927\u5c0f\u3001\u53d6\u503c\u8303\u56f4\u548c\u53ef\u6267\u884c\u64cd\u4f5c&#xff1b;\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u7528\u4e8e\u5b9e\u73b0\u4e0d\u540c\u7c7b\u578b\u95f4\u7684\u8f6c\u6362&#xff0c;C&#043;&#043;\u63d0\u4f9b\u4e86\u7c7b\u578b\u5b89\u5168\u7684\u8f6c\u6362\u8fd0\u7b97\u7b26&#xff0c;\u66ff\u4ee3C\u8bed\u8a00\u7684\u9690\u5f0f\u8f6c\u6362&#xff0c;\u660e\u786e\u8f6c\u6362\u610f\u56fe\u3002<\/p>\n<h4>1. \u57fa\u672c\u6570\u636e\u7c7b\u578b<\/h4>\n<p>C&#043;&#043;\u7684\u57fa\u672c\u6570\u636e\u7c7b\u578b\u5206\u4e3a\u6574\u578b\u3001\u6d6e\u70b9\u578b\u3001\u5b57\u7b26\u578b\u3001\u5e03\u5c14\u578b&#xff0c;\u5176\u4e2d\u6574\u578b\u9075\u5faa**\u201c\u6700\u5c0f\u957f\u5ea6\u89c4\u5219\u201d**&#xff0c;\u5177\u4f53\u957f\u5ea6\u53ef\u901a\u8fc7sizeof\u8fd0\u7b97\u7b26\u67e5\u8be2&#xff0c;\u4e0d\u540c\u5e73\u53f0\u53ef\u80fd\u7565\u6709\u5dee\u5f02&#xff0c;\u6838\u5fc3\u7c7b\u578b\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\u6574\u578b&#xff1a;short&#xff08;\u81f3\u5c1116\u4f4d\/2\u5b57\u8282&#xff09;\u3001int&#xff08;\u81f3\u5c11\u4e0eshort\u7b49\u957f&#xff0c;\u901a\u5e3832\u4f4d\/4\u5b57\u8282&#xff09;\u3001long&#xff08;\u81f3\u5c1132\u4f4d\/4\u5b57\u8282&#xff09;\u3001long long&#xff08;\u81f3\u5c1164\u4f4d\/8\u5b57\u8282&#xff09;&#xff1b;<\/li>\n<li>\u65e0\u7b26\u53f7\u6574\u578b&#xff1a;\u5728\u6574\u578b\u524d\u52a0unsigned&#xff0c;\u5982unsigned int\u3001unsigned long&#xff0c;\u4e0d\u5b58\u50a8\u8d1f\u6570&#xff0c;\u6700\u5927\u503c\u4e3a\u5bf9\u5e94\u6709\u7b26\u53f7\u6574\u578b\u76842\u500d&#xff0c;\u9002\u5408\u5b58\u50a8\u8ba1\u6570\u7c7b\u3001\u7d22\u5f15\u7c7b\u6570\u636e&#xff1b;<\/li>\n<li>\u6d6e\u70b9\u578b&#xff1a;float&#xff08;\u5355\u7cbe\u5ea6&#xff0c;4\u5b57\u8282&#xff09;\u3001double&#xff08;\u53cc\u7cbe\u5ea6&#xff0c;8\u5b57\u8282&#xff09;\u3001long double&#xff08;\u6269\u5c55\u7cbe\u5ea6&#xff0c;\u22658\u5b57\u8282&#xff09;&#xff0c;\u7528\u4e8e\u5b58\u50a8\u5c0f\u6570&#xff0c;\u53cc\u7cbe\u5ea6\u662f\u5f00\u53d1\u4e2d\u7684\u9ed8\u8ba4\u9009\u62e9&#xff1b;<\/li>\n<li>\u5b57\u7b26\u578b&#xff1a;char&#xff08;1\u5b57\u8282&#xff09;\u3001wchar_t&#xff08;\u5bbd\u5b57\u7b26&#xff0c;2\/4\u5b57\u8282&#xff09;&#xff0c;\u7528\u4e8e\u5b58\u50a8\u5355\u4e2a\u5b57\u7b26&#xff0c;char\u53ef\u5206\u4e3a\u6709\u7b26\u53f7&#xff08;\u9ed8\u8ba4&#xff09;\u548c\u65e0\u7b26\u53f7&#xff08;unsigned char&#xff09;&#xff1b;<\/li>\n<li>\u5e03\u5c14\u578b&#xff1a;bool&#xff0c;\u53d6\u503c\u4e3atrue&#xff08;1&#xff09;\u6216false&#xff08;0&#xff09;&#xff0c;\u7528\u4e8e\u903b\u8f91\u5224\u65ad\u3002<\/li>\n<\/ul>\n<p>\u6ce8\u610f&#xff1a;\u53ef\u901a\u8fc7&lt;climits&gt;\u3001&lt;cfloat&gt;\u5934\u6587\u4ef6\u67e5\u770b\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u7684\u53d6\u503c\u8303\u56f4&#xff0c;\u5982INT_MAX&#xff08;int\u7684\u6700\u5927\u503c&#xff09;\u3001FLT_MAX&#xff08;float\u7684\u6700\u5927\u503c&#xff09;\u3002<\/p>\n<h4>2. \u5f3a\u5236\u7c7b\u578b\u8f6c\u6362<\/h4>\n<p>C&#043;&#043;\u63d0\u4f9b4\u79cd\u7c7b\u578b\u5b89\u5168\u7684\u5f3a\u5236\u8f6c\u6362\u8fd0\u7b97\u7b26&#xff0c;\u66ff\u4ee3C\u8bed\u8a00\u7684(\u7c7b\u578b)\u53d8\u91cf\u9690\u5f0f\u8f6c\u6362&#xff0c;\u660e\u786e\u8f6c\u6362\u610f\u56fe&#xff0c;\u51cf\u5c11\u8f6c\u6362\u9519\u8bef&#xff0c;\u4e0d\u540c\u8fd0\u7b97\u7b26\u9002\u7528\u4e8e\u4e0d\u540c\u573a\u666f&#xff0c;\u4e0d\u53ef\u6df7\u7528\u3002<\/p>\n<table>\n<tr>\u8f6c\u6362\u8fd0\u7b97\u7b26\u9002\u7528\u573a\u666f\u7279\u6027\u5b89\u5168\u6027<\/tr>\n<tbody>\n<tr>\n<td>static_cast<\/td>\n<td>\u57fa\u672c\u7c7b\u578b\u8f6c\u6362\u3001\u4e0a\u884c\u8f6c\u6362&#xff08;\u6d3e\u751f\u7c7b\u2192\u57fa\u7c7b&#xff09;\u3001\u975econst\u8f6c\u975econst<\/td>\n<td>\u7f16\u8bd1\u671f\u68c0\u67e5&#xff0c;\u65e0\u8fd0\u884c\u65f6\u7c7b\u578b\u68c0\u67e5<\/td>\n<td>\u8f83\u9ad8&#xff08;\u9700\u5f00\u53d1\u8005\u4fdd\u8bc1\u8f6c\u6362\u5408\u7406\u6027&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>dynamic_cast<\/td>\n<td>\u542b\u865a\u51fd\u6570\u7684\u7c7b\u5c42\u6b21\u7ed3\u6784\u8f6c\u6362&#xff0c;\u4e3b\u8981\u7528\u4e8e\u4e0b\u884c\u8f6c\u6362&#xff08;\u57fa\u7c7b\u2192\u6d3e\u751f\u7c7b&#xff09;<\/td>\n<td>\u8fd0\u884c\u671f\u7c7b\u578b\u68c0\u67e5&#xff0c;\u57fa\u4e8eRTTI&#xff08;\u8fd0\u884c\u65f6\u7c7b\u578b\u4fe1\u606f&#xff09;<\/td>\n<td>\u6700\u9ad8&#xff08;\u8f6c\u6362\u5931\u8d25\u8fd4\u56denullptr\/\u629b\u51fa\u5f02\u5e38&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>reinterpret_cast<\/td>\n<td>\u4efb\u610f\u6307\u9488\/\u5f15\u7528\u4e4b\u95f4\u7684\u8f6c\u6362\u3001\u6307\u9488\u4e0e\u6574\u6570\u7684\u8f6c\u6362<\/td>\n<td>\u7f16\u8bd1\u671f\u5904\u7406&#xff0c;\u4ec5\u505a\u4e8c\u8fdb\u5236\u4f4d\u62f7\u8d1d&#xff0c;\u4e0d\u6539\u53d8\u6570\u636e<\/td>\n<td>\u6700\u4f4e&#xff08;\u5e73\u53f0\u79fb\u690d\u6027\u5dee&#xff0c;\u614e\u7528&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>const_cast<\/td>\n<td>\u79fb\u9664\u53d8\u91cf\u7684const\u6216volatile\u5c5e\u6027<\/td>\n<td>\u4ec5\u4f5c\u7528\u4e8e\u6307\u9488\/\u5f15\u7528&#xff0c;\u4e0d\u80fd\u76f4\u63a5\u4fee\u9970\u53d8\u91cf<\/td>\n<td>\u4e2d\u7b49&#xff08;\u4e0d\u53ef\u4fee\u6539\u539f\u5e38\u91cf\u503c&#xff0c;\u5426\u5219\u884c\u4e3a\u672a\u5b9a\u4e49&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ static_cast&#xff1a;\u57fa\u672c\u7c7b\u578b\u8f6c\u6362<\/span><br \/>\n<span class=\"token keyword\">int<\/span> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">double<\/span> b <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">static_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">double<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>a<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">\/<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ 3.33333<\/span><\/p>\n<p><span class=\"token comment\">\/\/ dynamic_cast&#xff1a;\u7c7b\u5c42\u6b21\u8f6c\u6362<\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Base<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">virtual<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">func<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Derived<\/span> <span class=\"token operator\">:<\/span> <span class=\"token base-clause\"><span class=\"token keyword\">public<\/span> <span class=\"token class-name\">Base<\/span><\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\nBase<span class=\"token operator\">*<\/span> p <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> Derived<span class=\"token punctuation\">;<\/span><br \/>\nDerived<span class=\"token operator\">*<\/span> d <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">dynamic_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span>Derived<span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>p<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u8f6c\u6362\u6210\u529f<\/span><\/p>\n<p><span class=\"token comment\">\/\/ const_cast&#xff1a;\u79fb\u9664const\u5c5e\u6027<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span> c <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">20<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span> pc <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">const_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>c<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/ *pc &#061; 30; \/\/ \u975e\u6cd5&#xff1a;\u4fee\u6539\u539f\u5e38\u91cf&#xff0c;\u884c\u4e3a\u672a\u5b9a\u4e49<\/span><\/p>\n<p><span class=\"token comment\">\/\/ reinterpret_cast&#xff1a;\u6307\u9488\u7c7b\u578b\u5f3a\u5236\u8f6c\u6362<\/span><br \/>\n<span class=\"token keyword\">int<\/span> x <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span> px <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&amp;<\/span>x<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> pc <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">reinterpret_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>px<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h3>\u4e94\u3001\u5b8f\u4e0e\u9ad8\u7ea7\u4fee\u9970\u7b26&#xff1a;\u6613\u6df7\u6dc6\u6838\u5fc3\u6982\u5ff5\u8fa8\u6790<\/h3>\n<p>\u5728C&#043;&#043;\u5f00\u53d1\u4e2d&#xff0c;#define\u5b8f\u3001inline\u3001constexpr\u3001volatile\u3001extern\u662f\u9ad8\u9891\u6613\u6df7\u6dc6\u7684\u8bed\u6cd5\u5143\u7d20&#xff0c;\u5176\u4e2d#define\u662fC\u8bed\u8a00\u517c\u5bb9\u7684\u9884\u5904\u7406\u8bed\u6cd5&#xff0c;\u5176\u4f59\u5747\u4e3aC&#043;&#043;\u7684\u9ad8\u7ea7\u4fee\u9970\u7b26&#xff0c;\u638c\u63e1\u5176\u5dee\u5f02\u662f\u7f16\u5199\u9ad8\u6548\u3001\u5b89\u5168\u4ee3\u7801\u7684\u5173\u952e\u3002<\/p>\n<h4>1. #define \u4e0e inline&#xff1a;\u5b8f\u66ff\u6362 vs \u5185\u8054\u51fd\u6570<\/h4>\n<p>\u4e8c\u8005\u5747\u8bd5\u56fe\u51cf\u5c11\u51fd\u6570\u8c03\u7528\u5f00\u9500&#xff0c;\u4f46\u5b9e\u73b0\u539f\u7406\u3001\u9636\u6bb5\u548c\u5b89\u5168\u6027\u5929\u5dee\u5730\u522b&#xff0c;inline\u662fC&#043;&#043;\u63a8\u8350\u7684\u51fd\u6570\u4f18\u5316\u624b\u6bb5&#xff0c;\u4f18\u5148\u7528inline\u66ff\u4ee3#define\u5b9a\u4e49\u5b8f\u51fd\u6570\u3002<\/p>\n<table>\n<tr>\u7279\u6027#define&#xff08;\u5b8f&#xff09;inline&#xff08;\u5185\u8054\u51fd\u6570&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u5904\u7406\u9636\u6bb5<\/td>\n<td>\u9884\u5904\u7406\u9636\u6bb5&#xff08;\u7f16\u8bd1\u524d&#xff09;&#xff0c;\u7eaf\u5b57\u7b26\u4e32\u66ff\u6362<\/td>\n<td>\u7f16\u8bd1\u9636\u6bb5&#xff0c;\u7f16\u8bd1\u5668\u505a\u4ee3\u7801\u5c55\u5f00\u4f18\u5316<\/td>\n<\/tr>\n<tr>\n<td>\u7c7b\u578b\u68c0\u67e5<\/td>\n<td>\u65e0\u4efb\u4f55\u7c7b\u578b\u68c0\u67e5&#xff0c;\u6613\u56e0\u53c2\u6570\u7c7b\u578b\u5bfc\u81f4\u9690\u5f0f\u9519\u8bef<\/td>\n<td>\u4e25\u683c\u7684\u53c2\u6570\/\u8fd4\u56de\u503c\u7c7b\u578b\u68c0\u67e5&#xff0c;\u7b26\u5408C&#043;&#043;\u8bed\u6cd5\u89c4\u5219<\/td>\n<\/tr>\n<tr>\n<td>\u4f5c\u7528\u57df<\/td>\n<td>\u5168\u5c40\u6709\u6548&#xff0c;\u9700\u7528#undef\u624b\u52a8\u7ec8\u6b62\u4f5c\u7528\u57df<\/td>\n<td>\u9075\u5faa\u51fd\u6570\u4f5c\u7528\u57df&#xff0c;\u53ef\u53d7namespace\/\u7c7b\u9650\u5236<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u7279\u6027<\/td>\n<td>\u65e0\u6808\u5e27\u5f00\u9500&#xff0c;\u4f46\u91cd\u590d\u66ff\u6362\u4f1a\u589e\u52a0\u4ee3\u7801\u6bb5\u4f53\u79ef&#xff08;\u4ee3\u7801\u81a8\u80c0&#xff09;<\/td>\n<td>\u65e0\u51fd\u6570\u8c03\u7528\u6808\u5e27\u5f00\u9500&#xff0c;\u7f16\u8bd1\u5668\u667a\u80fd\u5224\u65ad\u662f\u5426\u5c55\u5f00&#xff08;\u590d\u6742\u903b\u8f91\u81ea\u52a8\u653e\u5f03\u5185\u8054&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u652f\u6301\u7279\u6027<\/td>\n<td>\u4e0d\u652f\u6301\u9012\u5f52\u3001\u9ed8\u8ba4\u53c2\u6570\u3001\u51fd\u6570\u91cd\u8f7d<\/td>\n<td>\u652f\u6301\u9012\u5f52\u3001\u9ed8\u8ba4\u53c2\u6570\u3001\u51fd\u6570\u91cd\u8f7d&#xff0c;\u4e0e\u666e\u901a\u51fd\u6570\u4e00\u81f4<\/td>\n<\/tr>\n<tr>\n<td>\u5751\u70b9<\/td>\n<td>\u7f3a\u5c11\u62ec\u53f7\u6613\u51fa\u903b\u8f91\u9519\u8bef&#xff1a;#define MUL(a,b) a*b&#xff0c;\u8c03\u7528MUL(2&#043;3,4)\u5c55\u5f00\u4e3a2&#043;3*4&#061;14&#xff08;\u975e\u9884\u671f20&#xff09;<\/td>\n<td>\u4ec5\u9002\u7528\u4e8e\u77ed\u903b\u8f91\u3001\u9ad8\u9891\u8c03\u7528\u7684\u51fd\u6570&#xff08;\u5982getter\/\u7b80\u5355\u8ba1\u7b97&#xff09;&#xff0c;\u590d\u6742\u51fd\u6570\u5185\u8054\u65e0\u610f\u4e49<\/td>\n<\/tr>\n<tr>\n<td>\u793a\u4f8b<\/td>\n<td>#define ADD(a,b) ((a)&#043;(b))&#xff08;\u52a0\u62ec\u53f7\u907f\u514d\u9519\u8bef&#xff09;<\/td>\n<td>inline int add(int a, int b) { return a &#043; b; }<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2. #define \u4e0e const&#xff1a;\u5b8f\u5e38\u91cf vs \u5e38\u91cf\u53d8\u91cf<\/h4>\n<p>\u4e8c\u8005\u5747\u7528\u4e8e\u5b9a\u4e49\u201c\u4e0d\u53ef\u53d8\u503c\u201d&#xff0c;\u4f46const\u662fC&#043;&#043;\u5f3a\u7c7b\u578b\u7684\u5e38\u91cf\u4fee\u9970\u7b26&#xff0c;#define\u662f\u65e0\u7c7b\u578b\u7684\u9884\u5904\u7406\u66ff\u6362&#xff0c;\u751f\u4ea7\u73af\u5883\u4f18\u5148\u4f7f\u7528const\u66ff\u4ee3#define\u5b9a\u4e49\u5e38\u91cf\u3002<\/p>\n<table>\n<tr>\u7279\u6027#define&#xff08;\u5b8f\u5e38\u91cf&#xff09;const&#xff08;\u5e38\u91cf\u53d8\u91cf&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u7c7b\u578b\u5c5e\u6027<\/td>\n<td>\u65e0\u7c7b\u578b&#xff0c;\u4ec5\u505a\u5b57\u7b26\u4e32\u66ff\u6362&#xff0c;\u7f16\u8bd1\u5668\u65e0\u611f\u77e5<\/td>\n<td>\u6709\u660e\u786e\u7c7b\u578b&#xff0c;\u7f16\u8bd1\u5668\u4e25\u683c\u8fdb\u884c\u7c7b\u578b\u68c0\u67e5<\/td>\n<\/tr>\n<tr>\n<td>\u5904\u7406\u9636\u6bb5<\/td>\n<td>\u9884\u5904\u7406\u9636\u6bb5\u76f4\u63a5\u66ff\u6362&#xff0c;\u4e0d\u53c2\u4e0e\u7f16\u8bd1\u8fc7\u7a0b<\/td>\n<td>\u7f16\u8bd1\u9636\u6bb5\u5904\u7406&#xff0c;\u4f5c\u4e3a\u5e38\u91cf\u53d8\u91cf\u5b58\u5165\u5185\u5b58&#xff08;\u6570\u636e\u6bb5\u53ea\u8bfb\u533a\u57df&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u4f5c\u7528\u57df<\/td>\n<td>\u5168\u5c40\u6709\u6548&#xff0c;\u8de8\u6587\u4ef6\u53ef\u89c1&#xff0c;\u9700#undef\u7ec8\u6b62<\/td>\n<td>\u5c40\u90e8const&#xff1a;\u4f5c\u7528\u57df\u4e3a\u4ee3\u7801\u5757\/\u51fd\u6570&#xff1b;\u5168\u5c40const&#xff1a;\u9ed8\u8ba4\u6587\u4ef6\u5185\u79c1\u6709&#xff08;\u53ef\u901a\u8fc7extern\u6269\u5c55&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5360\u7528<\/td>\n<td>\u4e0d\u5206\u914d\u5185\u5b58&#xff0c;\u7f16\u8bd1\u65f6\u76f4\u63a5\u66ff\u6362\u4e3a\u5b57\u9762\u91cf<\/td>\n<td>\u5206\u914d\u5185\u5b58&#xff0c;\u6709\u552f\u4e00\u5185\u5b58\u5730\u5740&#xff0c;\u53ef\u53d6\u5740&#xff08;&amp;const_var&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u7c7b\u4e2d\u4f7f\u7528<\/td>\n<td>\u65e0\u6cd5\u4f5c\u4e3a\u7c7b\u6210\u5458&#xff08;\u9884\u5904\u7406\u9636\u6bb5\u65e0\u7c7b\u6982\u5ff5&#xff09;<\/td>\n<td>\u53ef\u4f5c\u4e3a\u7c7b\u6210\u5458&#xff0c;\u975e\u9759\u6001const\u9700\u5728\u6784\u9020\u51fd\u6570\u521d\u59cb\u5316\u5217\u8868\u521d\u59cb\u5316&#xff0c;\u9759\u6001const\u9700\u7c7b\u5916\u521d\u59cb\u5316<\/td>\n<\/tr>\n<tr>\n<td>\u793a\u4f8b<\/td>\n<td>#define PI 3.1415926  #define MAX_LEN 1024<\/td>\n<td>const double PI &#061; 3.1415926;  const int MAX_LEN &#061; 1024;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3. constexpr \u4e0e const&#xff1a;\u7f16\u8bd1\u671f\u5e38\u91cf vs \u8fd0\u884c\u671f\u53ea\u8bfb\u53d8\u91cf<\/h4>\n<p>C&#043;&#043;11\u5f15\u5165constexpr&#xff0c;\u5f3a\u5316\u4e86\u201c\u7f16\u8bd1\u671f\u5e38\u91cf\u201d\u7684\u8bed\u4e49&#xff0c;\u5f25\u8865\u4e86const\u201c\u53ea\u8bfb\u4f46\u672a\u5fc5\u662f\u7f16\u8bd1\u671f\u5e38\u91cf\u201d\u7684\u7f3a\u9677&#xff0c;constexpr\u662f\u66f4\u5f3a\u7684const\u3002<\/p>\n<table>\n<tr>\u7279\u6027const&#xff08;\u53ea\u8bfb\u53d8\u91cf&#xff09;constexpr&#xff08;\u7f16\u8bd1\u671f\u5e38\u91cf&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u6838\u5fc3\u8bed\u4e49<\/td>\n<td>\u521d\u59cb\u5316\u540e\u503c\u4e0d\u53ef\u4fee\u6539&#xff0c;\u503c\u53ef\u8fd0\u884c\u671f\u786e\u5b9a<\/td>\n<td>\u503c\u5fc5\u987b\u5728\u7f16\u8bd1\u9636\u6bb5\u8ba1\u7b97\u5b8c\u6210&#xff0c;\u8fd0\u884c\u671f\u4e0d\u53ef\u4fee\u6539<\/td>\n<\/tr>\n<tr>\n<td>\u521d\u59cb\u5316\u503c<\/td>\n<td>\u53ef\u63a5\u53d7\u7f16\u8bd1\u671f\u5e38\u91cf&#xff08;\u5982const int a&#061;10&#xff09;\u6216\u8fd0\u884c\u671f\u5e38\u91cf&#xff08;\u5982const int a&#061;rand()&#xff09;<\/td>\n<td>\u5fc5\u987b\u662f\u7f16\u8bd1\u671f\u53ef\u8ba1\u7b97\u7684\u5e38\u91cf\u8868\u8fbe\u5f0f&#xff08;\u5b57\u9762\u91cf\u3001constexpr\u53d8\u91cf\u3001constexpr\u51fd\u6570\u8fd4\u56de\u503c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5360\u7528<\/td>\n<td>\u5206\u914d\u5185\u5b58&#xff08;\u6570\u636e\u6bb5&#xff09;&#xff0c;\u6709\u5185\u5b58\u5730\u5740&#xff0c;\u53ef\u53d6\u5740<\/td>\n<td>\u7f16\u8bd1\u671f\u76f4\u63a5\u66ff\u6362\u4e3a\u5b57\u9762\u91cf&#xff0c;\u901a\u5e38\u4e0d\u5206\u914d\u5185\u5b58&#xff1b;\u82e5\u53d6\u5740\u5219\u5206\u914d\u53ea\u8bfb\u5185\u5b58<\/td>\n<\/tr>\n<tr>\n<td>\u51fd\u6570\u4fee\u9970<\/td>\n<td>\u4e0d\u53ef\u4fee\u9970\u51fd\u6570&#xff0c;\u4ec5\u80fd\u4fee\u9970\u7c7b\u6210\u5458\u51fd\u6570\u4e3aconst<\/td>\n<td>\u53ef\u4fee\u9970constexpr\u51fd\u6570&#xff0c;\u8981\u6c42\u51fd\u6570\u4f53\u4e3a\u7f16\u8bd1\u671f\u53ef\u6267\u884c\u7684\u7b80\u5355\u903b\u8f91&#xff08;\u65e0\u5faa\u73af\/\u52a8\u6001\u5185\u5b58&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u7c7b\u4e2d\u4f7f\u7528<\/td>\n<td>\u9759\u6001const\u6210\u5458\u9700\u7c7b\u5916\u521d\u59cb\u5316&#xff1b;\u975e\u9759\u6001const\u6210\u5458\u9700\u6784\u9020\u51fd\u6570\u521d\u59cb\u5316\u5217\u8868\u521d\u59cb\u5316<\/td>\n<td>\u9759\u6001constexpr\u6210\u5458\u53ef\u76f4\u63a5\u5728\u7c7b\u5185\u521d\u59cb\u5316&#xff08;C&#043;&#043;11\u53ca\u4ee5\u4e0a&#xff09;&#xff0c;\u65e0\u9700\u7c7b\u5916\u5b9a\u4e49<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u573a\u666f<\/td>\n<td>\u5b9a\u4e49\u8fd0\u884c\u671f\u53ea\u8bfb\u53d8\u91cf&#xff08;\u51fd\u6570\u5185\u4e34\u65f6\u53ea\u8bfb\u503c\u3001\u7c7b\u5b9e\u4f8b\u7684\u53ea\u8bfb\u5c5e\u6027&#xff09;<\/td>\n<td>\u5b9a\u4e49\u7f16\u8bd1\u671f\u786e\u5b9a\u7684\u5e38\u91cf&#xff08;\u6570\u7ec4\u5927\u5c0f\u3001\u6a21\u677f\u53c2\u6570\u3001\u7f16\u8bd1\u671f\u8ba1\u7b97\u3001\u786c\u4ef6\u5bc4\u5b58\u5668\u5730\u5740&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u793a\u4f8b<\/td>\n<td>const int a &#061; rand();&#xff08;\u5408\u6cd5&#xff0c;\u8fd0\u884c\u671f\u5e38\u91cf&#xff09;<\/td>\n<td>constexpr int a &#061; 10&#043;20;  constexpr int arr[a];&#xff08;\u6807\u51c6\u5408\u6cd5&#xff0c;\u7f16\u8bd1\u671f\u786e\u5b9a\u6570\u7ec4\u5927\u5c0f&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4. volatile&#xff1a;\u6613\u53d8\u53d8\u91cf\u4fee\u9970\u7b26&#xff0c;\u7981\u6b62\u7f16\u8bd1\u5668\u4f18\u5316<\/h4>\n<p>volatile\u662fC&#043;&#043;\u4e2d\u5bb9\u6613\u88ab\u5ffd\u7565\u4f46\u81f3\u5173\u91cd\u8981\u7684\u4fee\u9970\u7b26&#xff0c;\u6838\u5fc3\u8bed\u4e49\u662f**\u201c\u544a\u8bc9\u7f16\u8bd1\u5668&#xff1a;\u8be5\u53d8\u91cf\u7684\u503c\u53ef\u80fd\u88ab\u7a0b\u5e8f\u5916\u90e8\u56e0\u7d20\u4fee\u6539&#xff0c;\u7981\u6b62\u5bf9\u5176\u8fdb\u884c\u4efb\u4f55\u4f18\u5316\u201d**&#xff0c;\u786e\u4fdd\u6bcf\u6b21\u8bbf\u95ee\u90fd\u76f4\u63a5\u8bfb\u53d6\u5185\u5b58&#xff0c;\u800c\u975e\u7f13\u5b58\u5230\u5bc4\u5b58\u5668\u3002<\/p>\n<h5>\u6838\u5fc3\u7279\u6027<\/h5>\n<li>\u7981\u6b62\u7f16\u8bd1\u5668\u4f18\u5316&#xff1a;\u7f16\u8bd1\u5668\u4e0d\u4f1a\u5c06volatile\u53d8\u91cf\u7684\u503c\u7f13\u5b58\u5230\u5bc4\u5b58\u5668&#xff0c;\u6bcf\u6b21\u8bfb\u5199\u90fd\u76f4\u63a5\u8bbf\u95ee\u5185\u5b58&#xff0c;\u907f\u514d\u4f18\u5316\u5bfc\u81f4\u7684\u9519\u8bef&#xff1b;<\/li>\n<li>\u4e0d\u4fdd\u8bc1\u539f\u5b50\u6027&#xff1a;volatile\u4ec5\u4fdd\u8bc1\u5185\u5b58\u53ef\u89c1\u6027&#xff0c;\u4e0d\u4fdd\u8bc1\u591a\u7ebf\u7a0b\u4e0b\u7684\u64cd\u4f5c\u539f\u5b50\u6027&#xff08;\u5982volatile int a&#043;&#043;\u4ecd\u53ef\u80fd\u51fa\u73b0\u7ade\u6001\u6761\u4ef6&#xff0c;\u9700\u914d\u5408\u4e92\u65a5\u9501\/\u539f\u5b50\u64cd\u4f5c&#xff09;&#xff1b;<\/li>\n<li>\u53ef\u4e0econst\u7ed3\u5408&#xff1a;const volatile int a; \u8868\u793a\u201c\u53d8\u91cf\u503c\u4e0d\u53ef\u88ab\u672c\u7a0b\u5e8f\u4fee\u6539&#xff0c;\u4f46\u53ef\u80fd\u88ab\u5916\u90e8\u4fee\u6539&#xff0c;\u4e14\u6bcf\u6b21\u8bbf\u95ee\u90fd\u8bfb\u5185\u5b58\u201d&#xff0c;\u9002\u7528\u4e8e\u786c\u4ef6\u5bc4\u5b58\u5668\u64cd\u4f5c&#xff1b;<\/li>\n<li>\u65e0\u4f20\u9012\u6027&#xff1a;volatile int* p&#xff0c;p\u662f\u666e\u901a\u6307\u9488&#xff0c;*p\u662fvolatile\u503c&#xff0c;\u4fee\u6539p\u7684\u6307\u5411\u4e0d\u53d7\u9650\u5236\u3002<\/li>\n<h5>\u9002\u7528\u573a\u666f<\/h5>\n<ul>\n<li>\u5d4c\u5165\u5f0f\u5f00\u53d1&#xff1a;\u786c\u4ef6\u5bc4\u5b58\u5668\u64cd\u4f5c&#xff08;\u5bc4\u5b58\u5668\u5730\u5740\u56fa\u5b9a&#xff0c;\u503c\u53ef\u80fd\u88ab\u786c\u4ef6\/\u5916\u8bbe\u4fee\u6539&#xff09;&#xff1b;<\/li>\n<li>\u4e2d\u65ad\u5904\u7406\u7a0b\u5e8f&#xff1a;\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u4e2d\u4fee\u6539\u7684\u53d8\u91cf&#xff0c;\u9700\u9632\u6b62\u7f16\u8bd1\u5668\u4f18\u5316&#xff1b;<\/li>\n<li>\u591a\u7ebf\u7a0b\u5f00\u53d1&#xff1a;\u591a\u7ebf\u7a0b\u5171\u4eab\u7684\u53d8\u91cf&#xff0c;\u4fdd\u8bc1\u5185\u5b58\u53ef\u89c1\u6027&#xff08;\u9700\u914d\u5408\u5185\u5b58\u5c4f\u969c&#xff09;&#xff1b;<\/li>\n<li>\u4fe1\u53f7\u5904\u7406\u51fd\u6570&#xff1a;\u4fe1\u53f7\u5904\u7406\u4e2d\u4fee\u6539\u7684\u5168\u5c40\u53d8\u91cf&#xff0c;\u907f\u514d\u7f16\u8bd1\u5668\u4f18\u5316\u4e3a\u6b7b\u5faa\u73af\u3002<\/li>\n<\/ul>\n<h5>\u793a\u4f8b<\/h5>\n<p><span class=\"token comment\">\/\/ \u5d4c\u5165\u5f0f\u4e32\u53e3\u63a5\u6536\u5bc4\u5b58\u5668\u64cd\u4f5c&#xff08;\u5bc4\u5b58\u5668\u5730\u5740\u56fa\u5b9a&#xff0c;\u503c\u7531\u786c\u4ef6\u4fee\u6539&#xff09;<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">UART_RX_REG<\/span> <span class=\"token expression\"><span class=\"token number\">0x12345678<\/span> <\/span><span class=\"token comment\">\/\/ \u4e32\u53e3\u63a5\u6536\u5bc4\u5b58\u5668\u7269\u7406\u5730\u5740<\/span><\/span><br \/>\n<span class=\"token keyword\">volatile<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span> rx_reg <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">volatile<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>UART_RX_REG<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">read_uart_data<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span>rx_reg <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u5faa\u73af\u7b49\u5f85\u5bc4\u5b58\u5668\u503c\u53d8\u5316&#xff08;\u7981\u6b62\u7f16\u8bd1\u5668\u4f18\u5316\u4e3a\u6b7b\u5faa\u73af&#xff09;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> data <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">*<\/span>rx_reg<span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u76f4\u63a5\u8bfb\u53d6\u5185\u5b58\u4e2d\u7684\u5bc4\u5b58\u5668\u503c&#xff0c;\u83b7\u53d6\u786c\u4ef6\u6570\u636e<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h4>5. extern \u4e0e static&#xff1a;\u4f5c\u7528\u57df\u4e0e\u94fe\u63a5\u5c5e\u6027\u63a7\u5236&#xff08;\u53cd\u5411\u5173\u952e\u5b57&#xff09;<\/h4>\n<p>\u4e8c\u8005\u5747\u7528\u4e8e\u63a7\u5236\u53d8\u91cf\/\u51fd\u6570\u7684\u94fe\u63a5\u5c5e\u6027\u548c\u8de8\u6587\u4ef6\u8bbf\u95ee\u6027&#xff0c;\u662fC&#043;&#043;\u6a21\u5757\u5316\u5f00\u53d1\u7684\u6838\u5fc3\u4fee\u9970\u7b26&#xff0c;\u4f5c\u7528\u5b8c\u5168\u76f8\u53cd&#xff1a;extern\u5b9e\u73b0\u8de8\u6587\u4ef6\u5171\u4eab&#xff0c;static\u5b9e\u73b0\u6587\u4ef6\/\u4f5c\u7528\u57df\u79c1\u6709\u3002<\/p>\n<table>\n<tr>\u7279\u6027extern&#xff08;\u5916\u90e8\u94fe\u63a5&#xff09;static&#xff08;\u5185\u90e8\u94fe\u63a5&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u6838\u5fc3\u4f5c\u7528<\/td>\n<td>\u58f0\u660e\u8de8\u6587\u4ef6\u53ef\u89c1\u7684\u53d8\u91cf\/\u51fd\u6570&#xff0c;\u6307\u793a\u7f16\u8bd1\u5668\u201c\u53bb\u5176\u4ed6\u6587\u4ef6\u627e\u5b9a\u4e49\u201d<\/td>\n<td>\u9650\u5236\u53d8\u91cf\/\u51fd\u6570\u7684\u4f5c\u7528\u57df\u4e3a\u5f53\u524d\u6587\u4ef6&#xff0c;\u7981\u6b62\u8de8\u6587\u4ef6\u8bbf\u95ee&#xff0c;\u5b9e\u73b0\u201c\u6587\u4ef6\u79c1\u6709\u201d<\/td>\n<\/tr>\n<tr>\n<td>\u94fe\u63a5\u5c5e\u6027<\/td>\n<td>\u5916\u90e8\u94fe\u63a5&#xff1a;\u591a\u4e2a\u6587\u4ef6\u53ef\u5171\u4eab\u540c\u4e00\u53d8\u91cf\/\u51fd\u6570\u5b9e\u4f53<\/td>\n<td>\u5185\u90e8\u94fe\u63a5&#xff1a;\u4ec5\u5f53\u524d\u6587\u4ef6\u53ef\u89c1&#xff0c;\u5176\u4ed6\u6587\u4ef6\u53ef\u5b9a\u4e49\u540c\u540d\u5b9e\u4f53&#xff0c;\u4e92\u4e0d\u5f71\u54cd<\/td>\n<\/tr>\n<tr>\n<td>\u53d8\u91cf\u4fee\u9970<\/td>\n<td>1. extern int a;&#xff1a;\u4ec5\u58f0\u660e&#xff0c;\u4e0d\u5206\u914d\u5185\u5b58&#xff1b;2. extern int a&#061;10;&#xff1a;\u5b9e\u9645\u662f\u5b9a\u4e49&#xff0c;\u5206\u914d\u5185\u5b58\u5e76\u521d\u59cb\u5316<\/td>\n<td>1. \u9759\u6001\u5c40\u90e8\u53d8\u91cf&#xff1a;\u5ef6\u957f\u751f\u547d\u5468\u671f\u81f3\u7a0b\u5e8f\u7ed3\u675f&#xff1b;2. \u9759\u6001\u5168\u5c40\u53d8\u91cf&#xff1a;\u6587\u4ef6\u5185\u79c1\u6709&#xff0c;\u9ed8\u8ba4\u521d\u59cb\u5316\u4e3a0<\/td>\n<\/tr>\n<tr>\n<td>\u51fd\u6570\u4fee\u9970<\/td>\n<td>extern void func();&#xff1a;\u58f0\u660e\u51fd\u6570\u5728\u5176\u4ed6\u6587\u4ef6\u5b9a\u4e49&#xff08;\u51fd\u6570\u9ed8\u8ba4\u5e26extern&#xff0c;\u53ef\u7701\u7565&#xff09;<\/td>\n<td>static void func();&#xff1a;\u51fd\u6570\u6587\u4ef6\u5185\u79c1\u6709&#xff0c;\u5176\u4ed6\u6587\u4ef6\u65e0\u6cd5\u8c03\u7528<\/td>\n<\/tr>\n<tr>\n<td>\u7c7b\u4e2d\u4f7f\u7528<\/td>\n<td>\u65e0\u76f4\u63a5\u4f5c\u7528&#xff08;\u7c7b\u6210\u5458\u6309\u8bbf\u95ee\u6743\u9650\u63a7\u5236&#xff09;<\/td>\n<td>\u4fee\u9970\u7c7b\u9759\u6001\u6210\u5458&#xff1a;\u6240\u6709\u5bf9\u8c61\u5171\u4eab&#xff0c;\u65e0this\u6307\u9488&#xff0c;\u7c7b\u5916\u521d\u59cb\u5316<\/td>\n<\/tr>\n<tr>\n<td>\u8de8\u6587\u4ef6\u793a\u4f8b<\/td>\n<td>\/\/ file1.cpp&#xff08;\u5b9a\u4e49&#xff09;int g_val &#061; 100;void show() { cout &lt;&lt; g_val; }\/\/ file2.cpp&#xff08;\u4f7f\u7528&#xff09;extern int g_val;extern void show();show(); \u2192 \u8f93\u51fa100<\/td>\n<td>\/\/ file1.cppstatic int g_val &#061; 100;static void show() { cout &lt;&lt; g_val; }\/\/ file2.cppextern int g_val; \u2192 \u7f16\u8bd1\u9519\u8bef&#xff08;\u627e\u4e0d\u5230\u5b9a\u4e49&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5173\u952e\u6ce8\u610f&#xff1a;\u5168\u5c40\u53d8\u91cf\/\u51fd\u6570\u9ed8\u8ba4\u5177\u6709extern\u5c5e\u6027&#xff0c;\u82e5\u60f3\u9650\u5236\u4e3a\u6587\u4ef6\u79c1\u6709&#xff0c;\u9700\u663e\u5f0f\u52a0static&#xff1b;extern\u4ec5\u4f5c\u58f0\u660e&#xff08;\u9664\u975e\u521d\u59cb\u5316&#xff09;&#xff0c;\u4e0d\u5206\u914d\u5185\u5b58&#xff0c;\u907f\u514d\u91cd\u590d\u5b9a\u4e49\u3002<\/p>\n<h3>\u516d\u3001\u51fd\u6570\u6307\u9488\u4e0e\u6307\u9488\u51fd\u6570<\/h3>\n<p>\u51fd\u6570\u6307\u9488\u548c\u6307\u9488\u51fd\u6570\u662fC&#043;&#043;\u4e2d\u6700\u6613\u6df7\u6dc6\u7684\u4e24\u4e2a\u6982\u5ff5&#xff0c;\u4e8c\u8005\u8bed\u6cd5\u4ec5\u5dee\u4e00\u5bf9\u62ec\u53f7&#xff0c;\u4f46\u672c\u8d28\u5b8c\u5168\u4e0d\u540c&#xff1a;\u51fd\u6570\u6307\u9488\u662f\u201c\u6307\u9488\u201d&#xff0c;\u6307\u5411\u51fd\u6570&#xff1b;\u6307\u9488\u51fd\u6570\u662f\u201c\u51fd\u6570\u201d&#xff0c;\u8fd4\u56de\u503c\u4e3a\u6307\u9488&#xff0c;\u662fC&#043;&#043;\u8fdb\u9636\u5f00\u53d1\u7684\u57fa\u7840\u3002<\/p>\n<h4>1. \u51fd\u6570\u6307\u9488&#xff1a;\u6307\u5411\u51fd\u6570\u7684\u6307\u9488\u53d8\u91cf<\/h4>\n<h5>\u6838\u5fc3\u6982\u5ff5<\/h5>\n<p>\u51fd\u6570\u5728\u5185\u5b58\u4e2d\u62e5\u6709\u552f\u4e00\u7684\u5165\u53e3\u5730\u5740&#xff0c;\u51fd\u6570\u6307\u9488\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u6307\u9488\u53d8\u91cf&#xff0c;\u5176\u503c\u4e3a\u51fd\u6570\u7684\u5185\u5b58\u5165\u53e3\u5730\u5740&#xff0c;\u901a\u8fc7\u51fd\u6570\u6307\u9488\u53ef\u4ee5\u95f4\u63a5\u8c03\u7528\u51fd\u6570&#xff0c;\u5b9e\u73b0\u201c\u51fd\u6570\u7684\u53c2\u6570\u5316\u4f20\u9012\u201d&#xff0c;\u662f\u56de\u8c03\u51fd\u6570\u3001\u7b56\u7565\u6a21\u5f0f\u7684\u6838\u5fc3\u57fa\u7840\u3002<\/p>\n<p>\u51fd\u6570\u6307\u9488\u7684\u7c7b\u578b\u7531\u51fd\u6570\u7684\u8fd4\u56de\u503c\u548c\u53c2\u6570\u5217\u8868\u51b3\u5b9a&#xff08;\u4e0e\u51fd\u6570\u540d\u65e0\u5173&#xff09;&#xff0c;\u51fd\u6570\u540d\u672c\u8eab\u5c31\u662f\u51fd\u6570\u7684\u5165\u53e3\u5730\u5740&#xff08;\u5982func\u7b49\u4ef7\u4e8e&amp;func&#xff09;\u3002<\/p>\n<h5>\u5b9a\u4e49\u8bed\u6cd5<\/h5>\n<p>\u51fd\u6570\u6307\u9488\u7684\u5b9a\u4e49\u9700\u4e25\u683c\u5339\u914d\u76ee\u6807\u51fd\u6570\u7684\u8fd4\u56de\u503c\u7c7b\u578b\u548c\u53c2\u6570\u5217\u8868&#xff08;\u7c7b\u578b&#043;\u4e2a\u6570&#043;\u987a\u5e8f&#xff09;&#xff0c;\u62ec\u53f7\u4e0d\u53ef\u7701\u7565&#xff08;\u4f18\u5148\u7ea7\u95ee\u9898&#xff09;&#xff0c;\u6709\u4e24\u79cd\u5b9a\u4e49\u65b9\u5f0f&#xff1a;<\/p>\n<ul>\n<li>\u76f4\u63a5\u5b9a\u4e49&#xff1a;\u8fd4\u56de\u503c\u7c7b\u578b (*\u51fd\u6570\u6307\u9488\u540d)(\u53c2\u6570\u7c7b\u578b1, \u53c2\u6570\u7c7b\u578b2, &#8230;); \u793a\u4f8b&#xff1a;int (*pFunc)(int, int); \/\/ \u6307\u5411\u201c\u63a5\u6536\u4e24\u4e2aint\u3001\u8fd4\u56deint\u201d\u7684\u51fd\u6570<\/li>\n<li>\u7c7b\u578b\u522b\u540d\u5b9a\u4e49&#xff08;\u63a8\u8350&#xff0c;\u7b80\u5316\u590d\u6742\u7c7b\u578b&#xff09;&#xff1a;<span class=\"token keyword\">typedef<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span>FuncType<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ typedef\u65b9\u5f0f<\/span><br \/>\n<span class=\"token keyword\">using<\/span> FuncType <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ C&#043;&#043;11 using\u65b9\u5f0f&#xff08;\u66f4\u76f4\u89c2&#xff09;<\/span><br \/>\nFuncType pFunc<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u5b9a\u4e49\u51fd\u6570\u6307\u9488\u53d8\u91cf<\/span>\n <\/li>\n<\/ul>\n<h5>\u4f7f\u7528\u6b65\u9aa4\u4e0e\u793a\u4f8b<\/h5>\n<p>\u6b65\u9aa4&#xff1a;\u5b9a\u4e49\u5339\u914d\u7684\u51fd\u6570 \u2192 \u5c06\u51fd\u6570\u5730\u5740\u8d4b\u503c\u7ed9\u51fd\u6570\u6307\u9488 \u2192 \u901a\u8fc7\u51fd\u6570\u6307\u9488\u95f4\u63a5\u8c03\u7528\u51fd\u6570&#xff08;*\u53ef\u7701\u7565&#xff09;\u3002<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;iostream&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">using<\/span> <span class=\"token keyword\">namespace<\/span> std<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ 1. \u5b9a\u4e49\u5339\u914d\u7684\u51fd\u6570<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">return<\/span> a <span class=\"token operator\">&#043;<\/span> b<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">sub<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">return<\/span> a <span class=\"token operator\">&#8211;<\/span> b<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ 2. \u5b9a\u4e49\u51fd\u6570\u6307\u9488\u5e76\u8d4b\u503c&#xff08;&amp;\u53ef\u7701\u7565&#xff09;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span>pFunc<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;<\/span> add<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ 3. \u95f4\u63a5\u8c03\u7528\u51fd\u6570&#xff08;\u4e24\u79cd\u65b9\u5f0f\u7b49\u4ef7&#xff0c;*\u53ef\u7701\u7565&#xff09;<\/span><br \/>\n    cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span>pFunc<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u6807\u51c6\u5199\u6cd5&#xff0c;\u8f93\u51fa5<\/span><br \/>\n    cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token function\">pFunc<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/ \u7b80\u5316\u5199\u6cd5&#xff0c;\u8f93\u51fa3<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u91cd\u65b0\u6307\u5411\u5176\u4ed6\u5339\u914d\u51fd\u6570<\/span><br \/>\n    pFunc <span class=\"token operator\">&#061;<\/span> sub<span class=\"token punctuation\">;<\/span><br \/>\n    cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token function\">pFunc<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/ \u8f93\u51fa3<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h5>\u6838\u5fc3\u4f7f\u7528\u573a\u666f<\/h5>\n<ul>\n<li>\u56de\u8c03\u51fd\u6570&#xff1a;\u64cd\u4f5c\u5b8c\u6210\u540e\u81ea\u52a8\u8c03\u7528\u9884\u5148\u6ce8\u518c\u7684\u51fd\u6570&#xff0c;\u5982C\u8bed\u8a00qsort\u7684\u6bd4\u8f83\u51fd\u6570\u3001\u5f02\u6b65\u64cd\u4f5c\u7684\u5b8c\u6210\u56de\u8c03\u3001\u6846\u67b6\u94a9\u5b50\u51fd\u6570&#xff1b;<\/li>\n<li>\u7b56\u7565\u6a21\u5f0f&#xff1a;\u5c06\u4e0d\u540c\u4e1a\u52a1\u903b\u8f91\u5c01\u88c5\u4e3a\u51fd\u6570&#xff0c;\u901a\u8fc7\u51fd\u6570\u6307\u9488\u52a8\u6001\u9009\u62e9\u6267\u884c\u7b56\u7565&#xff0c;\u66ff\u4ee3\u5927\u91cfif-else\/switch&#xff0c;\u63d0\u5347\u4ee3\u7801\u7075\u6d3b\u6027&#xff1b;<\/li>\n<li>\u7c7b\u7684\u6210\u5458\u51fd\u6570\u6307\u9488&#xff1a;\u7c7b\u7684\u975e\u9759\u6001\u6210\u5458\u51fd\u6570\u542b\u9690\u5f0fthis\u6307\u9488&#xff0c;\u9700\u6307\u5b9a\u7c7b\u540d\u5b9a\u4e49&#xff1a;int (Math::*pMemFunc)(int, int) &#061; &amp;Math::add;&#xff08;&amp;\u4e0d\u53ef\u7701\u7565&#xff09;&#xff1b;<\/li>\n<li>\u51fd\u6570\u8868\/\u63d2\u4ef6\u67b6\u6784&#xff1a;\u901a\u8fc7\u51fd\u6570\u6307\u9488\u6570\u7ec4\u5b58\u50a8\u591a\u4e2a\u540c\u7c7b\u578b\u51fd\u6570&#xff0c;\u5b9e\u73b0\u52a8\u6001\u51fd\u6570\u8c03\u7528&#xff0c;\u9002\u7528\u4e8e\u63d2\u4ef6\u3001\u9a71\u52a8\u5f00\u53d1\u3002<\/li>\n<\/ul>\n<p>\u56de\u8c03\u51fd\u6570\u793a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;iostream&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;cstdlib&gt;<\/span> <span class=\"token comment\">\/\/ qsort\u5934\u6587\u4ef6<\/span><\/span><br \/>\n<span class=\"token keyword\">using<\/span> <span class=\"token keyword\">namespace<\/span> std<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u56de\u8c03\u51fd\u65701&#xff1a;int\u5347\u5e8f\u6bd4\u8f83<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">compare_asc<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">void<\/span><span class=\"token operator\">*<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">void<\/span><span class=\"token operator\">*<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>a <span class=\"token operator\">&#8211;<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>b<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u56de\u8c03\u51fd\u65702&#xff1a;int\u964d\u5e8f\u6bd4\u8f83<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">compare_desc<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">void<\/span><span class=\"token operator\">*<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">void<\/span><span class=\"token operator\">*<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>b <span class=\"token operator\">&#8211;<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>a<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> arr<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">4<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> n <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>arr<span class=\"token punctuation\">)<\/span><span class=\"token operator\">\/<\/span><span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>arr<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ qsort\u7b2c\u56db\u4e2a\u53c2\u6570\u662f\u51fd\u6570\u6307\u9488&#xff1a;\u52a8\u6001\u4f20\u9012\u6bd4\u8f83\u7b56\u7565<\/span><br \/>\n    <span class=\"token function\">qsort<\/span><span class=\"token punctuation\">(<\/span>arr<span class=\"token punctuation\">,<\/span> n<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> compare_asc<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u5347\u5e8f\u6392\u5e8f<\/span><br \/>\n    <span class=\"token keyword\">for<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> x <span class=\"token operator\">:<\/span> arr<span class=\"token punctuation\">)<\/span> cout <span class=\"token operator\">&lt;&lt;<\/span> x <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034; &#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ 1 2 3 4<\/span><\/p>\n<p>    <span class=\"token function\">qsort<\/span><span class=\"token punctuation\">(<\/span>arr<span class=\"token punctuation\">,<\/span> n<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> compare_desc<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u964d\u5e8f\u6392\u5e8f<\/span><br \/>\n    <span class=\"token keyword\">for<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> x <span class=\"token operator\">:<\/span> arr<span class=\"token punctuation\">)<\/span> cout <span class=\"token operator\">&lt;&lt;<\/span> x <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034; &#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ 4 3 2 1<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h4>2. \u6307\u9488\u51fd\u6570&#xff1a;\u8fd4\u56de\u6307\u9488\u7c7b\u578b\u7684\u51fd\u6570<\/h4>\n<h5>\u6838\u5fc3\u6982\u5ff5<\/h5>\n<p>\u6307\u9488\u51fd\u6570\u662f\u4e00\u79cd\u666e\u901a\u51fd\u6570&#xff0c;\u5176\u6838\u5fc3\u7279\u5f81\u662f\u8fd4\u56de\u503c\u4e3a\u6307\u9488\u7c7b\u578b&#xff0c;\u8bed\u6cd5\u4e0a\u65e0\u7279\u6b8a\u4fee\u9970&#xff0c;\u4ec5\u9700\u5c06\u8fd4\u56de\u503c\u7c7b\u578b\u58f0\u660e\u4e3a\u6307\u9488\u5373\u53ef&#xff0c;\u662f\u52a8\u6001\u5185\u5b58\u5206\u914d\u3001\u8fd4\u56de\u6570\u7ec4\/\u5bf9\u8c61\u5730\u5740\u7684\u5e38\u7528\u65b9\u5f0f\u3002<\/p>\n<h5>\u5b9a\u4e49\u8bed\u6cd5<\/h5>\n<p>\u8fd4\u56de\u503c\u7c7b\u578b* \u51fd\u6570\u540d(\u53c2\u6570\u7c7b\u578b1, \u53c2\u6570\u7c7b\u578b2, &#8230;); \u793a\u4f8b&#xff1a;int* createArr(int n); \/\/ \u8fd4\u56deint\u7c7b\u578b\u6307\u9488\u7684\u51fd\u6570&#xff0c;\u63a5\u6536\u4e00\u4e2aint\u53c2\u6570<\/p>\n<h5>\u4f7f\u7528\u793a\u4f8b<\/h5>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;iostream&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">using<\/span> <span class=\"token keyword\">namespace<\/span> std<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u6307\u9488\u51fd\u6570&#xff1a;\u52a8\u6001\u521b\u5efaint\u6570\u7ec4&#xff0c;\u8fd4\u56de\u6570\u7ec4\u6307\u9488<\/span><br \/>\n<span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span> <span class=\"token function\">createArr<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> n<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>n <span class=\"token operator\">&lt;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span> <span class=\"token keyword\">nullptr<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span> arr <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">[<\/span>n<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u52a8\u6001\u5206\u914d\u5806\u5185\u5b58<\/span><br \/>\n    <span class=\"token keyword\">for<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&lt;<\/span>n<span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        arr<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> i <span class=\"token operator\">*<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u521d\u59cb\u5316\u6570\u7ec4<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> arr<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u8fd4\u56de\u5806\u5185\u5b58\u6307\u9488<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span><span class=\"token operator\">*<\/span> p <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">createArr<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>p <span class=\"token operator\">!&#061;<\/span> <span class=\"token keyword\">nullptr<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">for<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&lt;<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            cout <span class=\"token operator\">&lt;&lt;<\/span> p<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034; &#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ 0 2 4 6 8<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token keyword\">delete<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> p<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u624b\u52a8\u91ca\u653e\u5806\u5185\u5b58&#xff0c;\u907f\u514d\u6cc4\u6f0f<\/span><br \/>\n        p <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">nullptr<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h5>\u6838\u5fc3\u6ce8\u610f\u4e8b\u9879<\/h5>\n<ul>\n<li>\u6307\u9488\u51fd\u6570\u4e0d\u80fd\u8fd4\u56de\u6808\u5185\u5b58\u6307\u9488&#xff08;\u5982int* func() { int a; return &amp;a; }&#xff09;&#xff0c;\u6808\u5185\u5b58\u968f\u51fd\u6570\u8c03\u7528\u7ed3\u675f\u9500\u6bc1&#xff0c;\u8fd4\u56de\u540e\u4f1a\u6210\u4e3a\u60ac\u7a7a\u6307\u9488&#xff1b;<\/li>\n<li>\u82e5\u8fd4\u56de\u5806\u5185\u5b58\u6307\u9488&#xff0c;\u8c03\u7528\u8005\u9700\u624b\u52a8\u91ca\u653e\u5185\u5b58&#xff08;delete\/delete[]&#xff09;&#xff0c;\u907f\u514d\u5185\u5b58\u6cc4\u6f0f&#xff1b;<\/li>\n<li>\u6307\u9488\u51fd\u6570\u7684\u8fd4\u56de\u503c\u53ef\u505a\u94fe\u5f0f\u8bbf\u95ee&#xff0c;\u5982node* getNext(node* p) { return p-&gt;next; }&#xff0c;\u53ef\u8fde\u7eed\u8c03\u7528getNext(getNext(p))\u3002<\/li>\n<\/ul>\n<h4>3. \u51fd\u6570\u6307\u9488\u4e0e\u6307\u9488\u51fd\u6570\u6838\u5fc3\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u7279\u6027\u51fd\u6570\u6307\u9488&#xff08;\u6307\u9488&#xff09;\u6307\u9488\u51fd\u6570&#xff08;\u51fd\u6570&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u672c\u8d28<\/td>\n<td>\u7279\u6b8a\u7684\u6307\u9488\u53d8\u91cf&#xff0c;\u6307\u5411\u51fd\u6570\u7684\u5165\u53e3\u5730\u5740<\/td>\n<td>\u666e\u901a\u7684\u51fd\u6570&#xff0c;\u8fd4\u56de\u503c\u4e3a\u6307\u9488\u7c7b\u578b<\/td>\n<\/tr>\n<tr>\n<td>\u6838\u5fc3\u8bed\u6cd5<\/td>\n<td>\u62ec\u53f7\u4e0d\u53ef\u7701\u7565&#xff1a;int (*p)(int, int)<\/td>\n<td>\u65e0\u989d\u5916\u62ec\u53f7&#xff1a;int* f(int, int)<\/td>\n<\/tr>\n<tr>\n<td>\u4f18\u5148\u7ea7\u5173\u952e<\/td>\n<td>(*p)\u63d0\u5347*\u4f18\u5148\u7ea7&#xff0c;\u5148\u8868\u793a\u6307\u9488&#xff0c;\u518d\u5173\u8054\u51fd\u6570<\/td>\n<td>\u51fd\u6570\u8c03\u7528\u7b26()\u4f18\u5148\u7ea7\u9ad8\u4e8e*&#xff0c;\u5148\u8868\u793a\u51fd\u6570&#xff0c;\u518d\u5173\u8054\u8fd4\u56de\u503c\u6307\u9488<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5b58\u50a8<\/td>\n<td>\u5b58\u50a8\u5728\u6808\u533a\/\u6570\u636e\u6bb5&#xff08;\u6307\u9488\u53d8\u91cf&#xff09;&#xff0c;\u503c\u4e3a\u51fd\u6570\u4ee3\u7801\u6bb5\u5730\u5740<\/td>\n<td>\u672c\u8eab\u662f\u51fd\u6570\u4ee3\u7801\u6bb5&#xff0c;\u8fd4\u56de\u503c\u662f\u6307\u5411\u6808\/\u5806\/\u6570\u636e\u6bb5\u7684\u6307\u9488<\/td>\n<\/tr>\n<tr>\n<td>\u6838\u5fc3\u7528\u9014<\/td>\n<td>\u56de\u8c03\u51fd\u6570\u3001\u7b56\u7565\u6a21\u5f0f\u3001\u52a8\u6001\u51fd\u6570\u8c03\u7528\u3001\u63d2\u4ef6\u67b6\u6784<\/td>\n<td>\u52a8\u6001\u5185\u5b58\u5206\u914d\u3001\u8fd4\u56de\u6570\u7ec4\/\u5bf9\u8c61\u5730\u5740\u3001\u94fe\u5f0f\u8bbf\u95ee<\/td>\n<\/tr>\n<tr>\n<td>\u6613\u6df7\u70b9<\/td>\n<td>\u7701\u7565\u62ec\u53f7\u5219\u53d8\u4e3a\u6307\u9488\u51fd\u6570&#xff1a;int *p(int, int)<\/td>\n<td>\u52a0\u62ec\u53f7\u5219\u8bed\u6cd5\u9519\u8bef&#xff1a;int* (f)(int, int)&#xff08;\u51fd\u6570\u540d\u4e0d\u80fd\u88ab\u62ec\u53f7\u5305\u88f9&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8bb0\u5fc6\u6280\u5de7&#xff1a;\u770b\u62ec\u53f7\u548c*\u7684\u7ed3\u5408\u5173\u7cfb\u2014\u2014(*\u540d)\u662f\u51fd\u6570\u6307\u9488&#xff08;\u540d\u662f\u6307\u9488&#xff09;&#xff0c;\u7c7b\u578b* \u540d()\u662f\u6307\u9488\u51fd\u6570&#xff08;\u540d\u662f\u51fd\u6570&#xff09;\u3002<\/p>\n<h3>\u4e03\u3001\u7ed3\u6784\u4f53\u4e0e\u7c7b&#xff1a;C&#043;&#043;\u9762\u5411\u5bf9\u8c61\u7684\u57fa\u7840\u8f7d\u4f53<\/h3>\n<p>struct\u548cclass\u662fC&#043;&#043;\u5b9e\u73b0\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u6838\u5fc3\u8f7d\u4f53&#xff0c;\u4e8c\u8005\u529f\u80fd\u51e0\u4e4e\u5b8c\u5168\u4e00\u81f4&#xff0c;\u4ec5\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650\u548c\u9ed8\u8ba4\u7ee7\u627f\u65b9\u5f0f\u4e0d\u540c&#xff0c;\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u7f16\u7a0b\u573a\u666f\u3002<\/p>\n<h4>1. \u6838\u5fc3\u533a\u522b<\/h4>\n<table>\n<tr>\u7279\u6027structclass<\/tr>\n<tbody>\n<tr>\n<td>\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650<\/td>\n<td>public&#xff08;\u516c\u6709&#xff09;&#xff1a;\u6210\u5458\u53ef\u76f4\u63a5\u88ab\u5916\u90e8\u8bbf\u95ee<\/td>\n<td>private&#xff08;\u79c1\u6709&#xff09;&#xff1a;\u6210\u5458\u4e0d\u53ef\u88ab\u5916\u90e8\u8bbf\u95ee&#xff0c;\u9700\u901a\u8fc7\u516c\u6709\u63a5\u53e3\u8bbf\u95ee<\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u7ee7\u627f\u65b9\u5f0f<\/td>\n<td>\u516c\u6709\u7ee7\u627f&#xff08;public&#xff09;&#xff1a;\u57fa\u7c7b\u7684\u516c\u6709\/\u4fdd\u62a4\u6210\u5458\u5728\u6d3e\u751f\u7c7b\u4e2d\u4fdd\u6301\u539f\u6709\u6743\u9650<\/td>\n<td>\u79c1\u6709\u7ee7\u627f&#xff08;private&#xff09;&#xff1a;\u57fa\u7c7b\u7684\u516c\u6709\/\u4fdd\u62a4\u6210\u5458\u5728\u6d3e\u751f\u7c7b\u4e2d\u53d8\u4e3a\u79c1\u6709<\/td>\n<\/tr>\n<tr>\n<td>\u6838\u5fc3\u8bbe\u8ba1\u610f\u56fe<\/td>\n<td>\u4fa7\u91cd\u7ec4\u7ec7\u6570\u636e&#xff0c;\u5b9e\u73b0\u6570\u636e\u7684\u805a\u5408&#xff0c;\u504f\u5411\u9762\u5411\u8fc7\u7a0b\u7f16\u7a0b<\/td>\n<td>\u4fa7\u91cd\u5c01\u88c5\u6570\u636e\u4e0e\u64cd\u4f5c&#xff0c;\u5b9e\u73b0\u5c5e\u6027\u548c\u65b9\u6cd5\u7684\u7ed1\u5b9a&#xff0c;\u504f\u5411\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u573a\u666f<\/td>\n<td>\u5b58\u50a8\u7b80\u5355\u7684\u7eaf\u6570\u636e\u7ed3\u6784&#xff08;\u5982\u5750\u6807\u3001\u5b66\u751f\u4fe1\u606f\u3001\u914d\u7f6e\u53c2\u6570&#xff09;<\/td>\n<td>\u5b9e\u73b0\u590d\u6742\u7684\u4e1a\u52a1\u903b\u8f91&#xff0c;\u5c01\u88c5\u5c5e\u6027\u548c\u65b9\u6cd5&#xff0c;\u652f\u6301\u7ee7\u627f\u3001\u591a\u6001\u7b49\u9762\u5411\u5bf9\u8c61\u7279\u6027<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2. \u5b9e\u7528\u793a\u4f8b<\/h4>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;iostream&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;string&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">using<\/span> <span class=\"token keyword\">namespace<\/span> std<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ struct&#xff1a;\u7eaf\u6570\u636e\u7ed3\u6784&#xff0c;\u9ed8\u8ba4public&#xff0c;\u4ec5\u5b58\u50a8\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">Student<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    string name<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u516c\u6709\u6210\u5458&#xff0c;\u53ef\u76f4\u63a5\u8bbf\u95ee<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> age<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">float<\/span> score<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ class&#xff1a;\u5c01\u88c5\u6570\u636e\u4e0e\u64cd\u4f5c&#xff0c;\u9ed8\u8ba4private&#xff0c;\u901a\u8fc7\u516c\u6709\u63a5\u53e3\u8bbf\u95ee<\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Calculator<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">private<\/span><span class=\"token operator\">:<\/span> <span class=\"token comment\">\/\/ \u9ed8\u8ba4private&#xff0c;\u5916\u90e8\u4e0d\u53ef\u8bbf\u95ee<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> result<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u79c1\u6709\u5c5e\u6027&#xff0c;\u4ec5\u7c7b\u5185\u53ef\u4fee\u6539<\/span><br \/>\n<span class=\"token keyword\">public<\/span><span class=\"token operator\">:<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u6784\u9020\u51fd\u6570&#xff1a;\u521d\u59cb\u5316\u5c5e\u6027<\/span><br \/>\n    <span class=\"token function\">Calculator<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">:<\/span> <span class=\"token function\">result<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u516c\u6709\u65b9\u6cd5&#xff1a;\u63d0\u4f9b\u5916\u90e8\u8bbf\u95ee\u63a5\u53e3<\/span><br \/>\n    <span class=\"token keyword\">void<\/span> <span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> num<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> result <span class=\"token operator\">&#043;&#061;<\/span> num<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">void<\/span> <span class=\"token function\">sub<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> num<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> result <span class=\"token operator\">-&#061;<\/span> num<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> <span class=\"token function\">getResult<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">return<\/span> result<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span> <span class=\"token comment\">\/\/ const\u6210\u5458\u51fd\u6570&#xff0c;\u4e0d\u4fee\u6539\u5c5e\u6027<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ struct\u4f7f\u7528&#xff1a;\u76f4\u63a5\u8bbf\u95ee\u6210\u5458<\/span><br \/>\n    Student s <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;\u5f20\u4e09&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">18<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">95.5<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;\u59d3\u540d&#xff1a;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> s<span class=\"token punctuation\">.<\/span>name <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034; \u5e74\u9f84&#xff1a;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> s<span class=\"token punctuation\">.<\/span>age <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ class\u4f7f\u7528&#xff1a;\u901a\u8fc7\u516c\u6709\u63a5\u53e3\u8bbf\u95ee<\/span><br \/>\n    Calculator cal<span class=\"token punctuation\">;<\/span><br \/>\n    cal<span class=\"token punctuation\">.<\/span><span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    cal<span class=\"token punctuation\">.<\/span><span class=\"token function\">sub<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;\u8ba1\u7b97\u7ed3\u679c&#xff1a;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> cal<span class=\"token punctuation\">.<\/span><span class=\"token function\">getResult<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ 7<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u6ce8\u610f&#xff1a;struct\u5728C&#043;&#043;\u4e2d\u5e76\u975e\u5355\u7eaf\u7684C\u8bed\u8a00\u7ed3\u6784\u4f53&#xff0c;\u4e5f\u652f\u6301\u6210\u5458\u51fd\u6570\u3001\u6784\u9020\u51fd\u6570\u3001\u7ee7\u627f\u3001\u591a\u6001\u7b49\u9762\u5411\u5bf9\u8c61\u7279\u6027&#xff0c;\u4ec5\u9ed8\u8ba4\u89c4\u5219\u4e0eclass\u4e0d\u540c&#xff1b;\u5f00\u53d1\u4e2d\u53ef\u6839\u636e\u8bbe\u8ba1\u610f\u56fe\u9009\u62e9&#xff0c;\u65e0\u9700\u4e25\u683c\u533a\u5206\u3002<\/p>\n<h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<p>C&#043;&#043;\u57fa\u7840\u77e5\u8bc6\u70b9\u6838\u5fc3\u56f4\u7ed5\u5185\u5b58\u7ba1\u7406\u3001\u7c7b\u578b\u5b89\u5168\u3001\u4f5c\u7528\u57df\u63a7\u5236\u3001\u4ee3\u7801\u89e3\u8026\u56db\u5927\u6838\u5fc3\u601d\u60f3\u5c55\u5f00&#xff0c;\u6838\u5fc3\u8981\u70b9\u53ef\u5f52\u7eb3\u4e3a&#xff1a;<\/p>\n<li>\u53d8\u91cf\u7ba1\u7406&#xff1a;\u638c\u63e1\u5c40\u90e8\u3001\u9759\u6001\u5c40\u90e8\u3001\u5168\u5c40\u53d8\u91cf\u7684\u751f\u547d\u5468\u671f\u548c\u5b58\u50a8\u4f4d\u7f6e&#xff0c;\u7406\u89e3\u6808\u533a\u3001\u6570\u636e\u6bb5\u7684\u5185\u5b58\u7279\u6027&#xff0c;\u907f\u514d\u5185\u5b58\u8d8a\u754c&#xff1b;<\/li>\n<li>\u5185\u5b58\u64cd\u4f5c&#xff1a;\u533a\u5206\u6307\u9488\u4e0e\u5f15\u7528\u7684\u672c\u8d28\u5dee\u5f02&#xff0c;\u5408\u7406\u4f7f\u7528\u6307\u9488\u5b9e\u73b0\u52a8\u6001\u5185\u5b58\u7ba1\u7406&#xff0c;\u4f18\u5148\u7528\u5f15\u7528\u7b80\u5316\u4ee3\u7801\u3001\u63d0\u5347\u5b89\u5168\u6027&#xff0c;\u675c\u7edd\u88f8\u6307\u9488\u7684\u5185\u5b58\u6cc4\u6f0f&#xff1b;<\/li>\n<li>\u5173\u952e\u5b57\u4f7f\u7528&#xff1a;\u638c\u63e1const&#xff08;\u53ea\u8bfb&#xff09;\u3001static&#xff08;\u4f5c\u7528\u57df\/\u751f\u547d\u5468\u671f&#xff09;\u7684\u591a\u573a\u666f\u8bed\u4e49&#xff0c;\u638c\u63e1new\/delete\u4e0emalloc\/free\u7684\u6838\u5fc3\u5dee\u5f02&#xff0c;\u4f18\u5148\u7528constexpr&#xff08;\u7f16\u8bd1\u671f\u5e38\u91cf&#xff09;\u3001inline&#xff08;\u5185\u8054\u51fd\u6570&#xff09;\u66ff\u4ee3#define&#xff0c;\u63d0\u5347\u4ee3\u7801\u7c7b\u578b\u5b89\u5168&#xff1b;<\/li>\n<li>\u7c7b\u578b\u8f6c\u6362&#xff1a;\u653e\u5f03C\u8bed\u8a00\u7684\u9690\u5f0f\u8f6c\u6362&#xff0c;\u4f7f\u7528C&#043;&#043;\u76844\u79cd\u7c7b\u578b\u5b89\u5168\u8f6c\u6362\u8fd0\u7b97\u7b26&#xff0c;\u6839\u636e\u573a\u666f\u9009\u62e9static_cast\/dynamic_cast\/const_cast\/reinterpret_cast&#xff1b;<\/li>\n<li>\u7279\u6b8a\u4fee\u9970\u7b26&#xff1a;volatile\u4fdd\u8bc1\u5185\u5b58\u53ef\u89c1\u6027&#xff08;\u786c\u4ef6\/\u591a\u7ebf\u7a0b&#xff09;&#xff0c;extern\/static\u63a7\u5236\u8de8\u6587\u4ef6\u8bbf\u95ee\u6027&#xff0c;\u5b9e\u73b0\u6a21\u5757\u5316\u5f00\u53d1&#xff1b;<\/li>\n<li>\u51fd\u6570\u6307\u9488&#xff1a;\u638c\u63e1\u51fd\u6570\u6307\u9488\u7684\u5b9a\u4e49\u548c\u4f7f\u7528&#xff0c;\u7406\u89e3\u5176\u5728\u56de\u8c03\u51fd\u6570\u3001\u7b56\u7565\u6a21\u5f0f\u4e2d\u7684\u6838\u5fc3\u4f5c\u7528&#xff0c;\u533a\u5206\u51fd\u6570\u6307\u9488\u4e0e\u6307\u9488\u51fd\u6570\u7684\u8bed\u6cd5\u5dee\u5f02&#xff1b;<\/li>\n<li>\u9762\u5411\u5bf9\u8c61\u57fa\u7840&#xff1a;\u7406\u89e3struct\u4e0eclass\u7684\u6838\u5fc3\u533a\u522b&#xff0c;\u638c\u63e1\u5c01\u88c5\u7684\u57fa\u672c\u601d\u60f3&#xff0c;\u901a\u8fc7\u7c7b\u7684\u516c\u6709\u63a5\u53e3\u8bbf\u95ee\u79c1\u6709\u6210\u5458&#xff0c;\u4fdd\u8bc1\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>C \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6<br \/>\nC\u4f5c\u4e3a\u4e00\u95e8\u517c\u5177\u9ad8\u6548\u6027\u548c\u7075\u6d3b\u6027\u7684\u7f16\u7a0b\u8bed\u8a00&#xff0c;\u662f\u7cfb\u7edf\u5f00\u53d1\u3001\u6e38\u620f\u5f15\u64ce\u3001\u5d4c\u5165\u5f0f\u7f16\u7a0b\u7b49\u9886\u57df\u7684\u6838\u5fc3\u5de5\u5177\u3002\u672c\u6587\u5c06\u4ece\u53d8\u91cf\u7c7b\u578b\u3001\u6307\u9488\u4e0e\u5f15\u7528\u3001\u6838\u5fc3\u5173\u952e\u5b57\u3001\u6570\u636e\u7c7b\u578b\u3001\u5b8f\u4e0e\u9ad8\u7ea7\u4fee\u9970\u7b26\u3001\u51fd\u6570\u6307\u9488\u7b49\u9ad8\u9891\u57fa\u7840\u77e5\u8bc6\u70b9\u5165\u624b&#xff0c;\u592f\u5b9e\u7f16\u7a0b\u57fa\u7840\u3002<br \/>\n\u4e00\u3001\u53d8\u91cf\u7684\u4e09\u7c7b\u6838\u5fc3\u5f62\u6001&#xff1a;\u5c40\u90e8\u3001\u9759\u6001\u5c40\u90e8\u3001\u5168\u5c40<br \/>\n\u53d8\u91cf\u662f\u7a0b\u5e8f\u5b58\u50a8\u6570\u636e\u7684\u57fa\u672c\u5355\u5143&#xff0c;\u6839\u636e\u4f5c\u7528\u57df\u3001\u751f\u547d\u5468\u671f\u548c\u5b58\u50a8\u4f4d\u7f6e\u7684\u5dee\u5f02&#xff0c;\u53ef\u5206\u4e3a\u5c40\u90e8\u53d8\u91cf\u3001\u9759\u6001\u5c40\u90e8\u53d8\u91cf\u548c\u5168\u5c40\u53d8\u91cf\u4e09\u7c7b&#xff0c;\u5176\u7279\u6027\u548c\u4f7f<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55],"topic":[],"class_list":["post-68378","post","type-post","status-publish","format-standard","hentry","category-server","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++ \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/68378.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++ \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"C \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6 C\u4f5c\u4e3a\u4e00\u95e8\u517c\u5177\u9ad8\u6548\u6027\u548c\u7075\u6d3b\u6027\u7684\u7f16\u7a0b\u8bed\u8a00&#xff0c;\u662f\u7cfb\u7edf\u5f00\u53d1\u3001\u6e38\u620f\u5f15\u64ce\u3001\u5d4c\u5165\u5f0f\u7f16\u7a0b\u7b49\u9886\u57df\u7684\u6838\u5fc3\u5de5\u5177\u3002\u672c\u6587\u5c06\u4ece\u53d8\u91cf\u7c7b\u578b\u3001\u6307\u9488\u4e0e\u5f15\u7528\u3001\u6838\u5fc3\u5173\u952e\u5b57\u3001\u6570\u636e\u7c7b\u578b\u3001\u5b8f\u4e0e\u9ad8\u7ea7\u4fee\u9970\u7b26\u3001\u51fd\u6570\u6307\u9488\u7b49\u9ad8\u9891\u57fa\u7840\u77e5\u8bc6\u70b9\u5165\u624b&#xff0c;\u592f\u5b9e\u7f16\u7a0b\u57fa\u7840\u3002 \u4e00\u3001\u53d8\u91cf\u7684\u4e09\u7c7b\u6838\u5fc3\u5f62\u6001&#xff1a;\u5c40\u90e8\u3001\u9759\u6001\u5c40\u90e8\u3001\u5168\u5c40 \u53d8\u91cf\u662f\u7a0b\u5e8f\u5b58\u50a8\u6570\u636e\u7684\u57fa\u672c\u5355\u5143&#xff0c;\u6839\u636e\u4f5c\u7528\u57df\u3001\u751f\u547d\u5468\u671f\u548c\u5b58\u50a8\u4f4d\u7f6e\u7684\u5dee\u5f02&#xff0c;\u53ef\u5206\u4e3a\u5c40\u90e8\u53d8\u91cf\u3001\u9759\u6001\u5c40\u90e8\u53d8\u91cf\u548c\u5168\u5c40\u53d8\u91cf\u4e09\u7c7b&#xff0c;\u5176\u7279\u6027\u548c\u4f7f\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/68378.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-29T19:57:09+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/68378.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/68378.html\",\"name\":\"C++ \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-29T19:57:09+00:00\",\"dateModified\":\"2026-01-29T19:57:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/68378.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/68378.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/68378.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++ \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C++ \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/68378.html","og_locale":"zh_CN","og_type":"article","og_title":"C++ \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"C \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6 C\u4f5c\u4e3a\u4e00\u95e8\u517c\u5177\u9ad8\u6548\u6027\u548c\u7075\u6d3b\u6027\u7684\u7f16\u7a0b\u8bed\u8a00&#xff0c;\u662f\u7cfb\u7edf\u5f00\u53d1\u3001\u6e38\u620f\u5f15\u64ce\u3001\u5d4c\u5165\u5f0f\u7f16\u7a0b\u7b49\u9886\u57df\u7684\u6838\u5fc3\u5de5\u5177\u3002\u672c\u6587\u5c06\u4ece\u53d8\u91cf\u7c7b\u578b\u3001\u6307\u9488\u4e0e\u5f15\u7528\u3001\u6838\u5fc3\u5173\u952e\u5b57\u3001\u6570\u636e\u7c7b\u578b\u3001\u5b8f\u4e0e\u9ad8\u7ea7\u4fee\u9970\u7b26\u3001\u51fd\u6570\u6307\u9488\u7b49\u9ad8\u9891\u57fa\u7840\u77e5\u8bc6\u70b9\u5165\u624b&#xff0c;\u592f\u5b9e\u7f16\u7a0b\u57fa\u7840\u3002 \u4e00\u3001\u53d8\u91cf\u7684\u4e09\u7c7b\u6838\u5fc3\u5f62\u6001&#xff1a;\u5c40\u90e8\u3001\u9759\u6001\u5c40\u90e8\u3001\u5168\u5c40 \u53d8\u91cf\u662f\u7a0b\u5e8f\u5b58\u50a8\u6570\u636e\u7684\u57fa\u672c\u5355\u5143&#xff0c;\u6839\u636e\u4f5c\u7528\u57df\u3001\u751f\u547d\u5468\u671f\u548c\u5b58\u50a8\u4f4d\u7f6e\u7684\u5dee\u5f02&#xff0c;\u53ef\u5206\u4e3a\u5c40\u90e8\u53d8\u91cf\u3001\u9759\u6001\u5c40\u90e8\u53d8\u91cf\u548c\u5168\u5c40\u53d8\u91cf\u4e09\u7c7b&#xff0c;\u5176\u7279\u6027\u548c\u4f7f","og_url":"https:\/\/www.wsisp.com\/helps\/68378.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-29T19:57:09+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"11 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/68378.html","url":"https:\/\/www.wsisp.com\/helps\/68378.html","name":"C++ \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-29T19:57:09+00:00","dateModified":"2026-01-29T19:57:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/68378.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/68378.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/68378.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C++ \u57fa\u7840\u6838\u5fc3\u77e5\u8bc6"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/68378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=68378"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/68378\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=68378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=68378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=68378"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=68378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}