{"id":89921,"date":"2026-08-04T07:08:36","date_gmt":"2026-08-03T23:08:36","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/89921.html"},"modified":"2026-08-04T07:08:36","modified_gmt":"2026-08-03T23:08:36","slug":"c-%e5%88%b0-c-%e4%b8%9d%e6%bb%91%e8%bf%87%e6%b8%a1%e6%95%99%e7%a8%8b%ef%bc%88%e5%85%a5%e9%97%a8%e5%9f%ba%e7%a1%80%e7%af%87%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/89921.html","title":{"rendered":"C \u5230 C++ \u4e1d\u6ed1\u8fc7\u6e21\u6559\u7a0b\uff08\u5165\u95e8\u57fa\u7840\u7bc7\uff09"},"content":{"rendered":"<h3>&#x1f4d1; \u76ee\u5f55<\/h3>\n<ul>\n<li>\u4e00\u3001namespace\n<ul>\n<li>1.1 namespace\u7684\u4ef7\u503c<\/li>\n<li>1.2 namespace\u7684\u5b9a\u4e49<\/li>\n<li>1.3 \u547d\u540d\u7a7a\u95f4\u7684\u4f7f\u7528<\/li>\n<\/ul>\n<\/li>\n<li>\u4e8c\u3001C&#043;&#043;\u8f93\u5165&amp;\u8f93\u51fa<\/li>\n<li>\u4e09\u3001\u7f3a\u7701\u53c2\u6570<\/li>\n<li>\u56db\u3001\u51fd\u6570\u91cd\u8f7d<\/li>\n<li>\u4e94\u3001\u5f15\u7528\n<ul>\n<li>5.1 \u5f15\u7528\u7684\u7279\u6027<\/li>\n<li>5.2 \u5f15\u7528\u7684\u4f7f\u7528<\/li>\n<li>5.3 \u6307\u9488\u4e0e\u5f15\u7528\u7684\u5173\u7cfb<\/li>\n<\/ul>\n<\/li>\n<li>\u516d\u3001const\u5f15\u7528 <\/li>\n<\/ul>\n<h3>\u4e00\u3001namespace<\/h3>\n<\/p>\n<h4>1.1 namespace\u7684\u4ef7\u503c<\/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;stdio.h&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;stdlib.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> rand <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u7f16\u8bd1\u62a5\u9519&#xff1a;\u201crand\u201d: \u91cd\u5b9a\u4e49&#xff1b;\u56e0\u4e3a\u5728\u5934\u6587\u4ef6stdlib.h\u4e2drand\u662f\u201c\u51fd\u6570\u540d\u201d <\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> rand<span class=\"token punctuation\">)<\/span><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<p>\u5728\u4e00\u4e2a\u9879\u76ee\u4e2d&#xff0c;\u547d\u540d\u51b2\u7a81\u662f\u5f88\u5e38\u89c1\u7684\u95ee\u9898&#xff0c;\u800cnamespace\u53ef\u4ee5\u5f88\u597d\u7684\u89e3\u51b3<\/p>\n<\/p>\n<h4>1.2 namespace\u7684\u5b9a\u4e49<\/h4>\n<ul>\n<li>\u5b9a\u4e49\u547d\u540d\u7a7a\u95f4\u9700\u8981\u7528\u5230\u5173\u952e\u5b57namespace&#xff0c;\u7ed3\u6784\u4e3anamespace&#043;\u7a7a\u95f4\u540d\u5b57&#043;{ }&#xff0c;{ }\u4e2d\u4e3a\u547d\u540d\u7a7a\u95f4\u7684\u6210\u5458 \u53ef\u4ee5\u5b9a\u4e49\u51fd\u6570\u3001\u53d8\u91cf\u7b49\u3002<\/li>\n<li>namespace\u672c\u8d28\u662f\u5b9a\u4e49\u4e00\u4e2a\u57df&#xff0c;\u8fd9\u4e2a\u57df\u8ddf\u5168\u5c40\u57df\u5404\u81ea\u72ec\u7acb \u5373\u4e0d\u540c\u7684\u57df\u53ef\u4ee5\u5b9a\u4e49\u540c\u540d\u53d8\u91cf\u3002<\/li>\n<li>namespace\u53ea\u80fd\u5b9a\u4e49\u5728\u5168\u5c40\u57df&#xff0c;\u4f46\u53ef\u4ee5\u5d4c\u5957\u5b9a\u4e49<\/li>\n<\/ul>\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;stdio.h&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;stdlib.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">namespace<\/span> Tian<span class=\"token punctuation\">{<\/span><br \/>\n   <span class=\"token keyword\">int<\/span> rand <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token comment\">\/\/\u547d\u540d\u7a7a\u95f4\u53ef\u4ee5\u5d4c\u5957<\/span><br \/>\n   <span class=\"token keyword\">namespace<\/span> Li<span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">int<\/span> rand <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">20<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token keyword\">namespace<\/span> Nuo<span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">int<\/span> rand <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">30<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<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\">\/\/ \u6253\u5370\u6807\u51c6\u5e93rand\u51fd\u6570\u7684\u5730\u5740&#xff08;\u51fd\u6570\u8981\u52a0&amp;&#xff09;<\/span><br \/>\n   <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%p\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>rand<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token comment\">\/\/\u8fd9\u91cc\u8bbf\u95ee\u6307\u5b9a\u547d\u540d\u7a7a\u95f4\u7684rand<\/span><br \/>\n   <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> Tian<span class=\"token double-colon punctuation\">::<\/span>rand<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/10<\/span><br \/>\n   <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span>Tian<span class=\"token double-colon punctuation\">::<\/span>Li<span class=\"token double-colon punctuation\">::<\/span>rand<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/20<\/span><br \/>\n   <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span>Tian<span class=\"token double-colon punctuation\">::<\/span>Nuo<span class=\"token double-colon punctuation\">::<\/span>rand<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/30<\/span><\/p>\n<p><span class=\"token punctuation\">}<\/span><\/p>\n<ul>\n<li>\u9879\u76ee\u4e2d\u591a\u6587\u4ef6\u4e2d\u540c\u540dnamespace&#xff0c;\u88ab\u8ba4\u4e3a\u662f\u4e00\u4e2anamespace&#xff0c;\u4e0d\u4f1a\u51b2\u7a81<\/li>\n<li>C&#043;&#043;\u6807\u51c6\u5e93\u90fd\u653e\u5728\u2f00\u4e2a\u53ebstd(standard)\u7684\u547d\u540d\u7a7a\u95f4\u4e2d\u3002<\/li>\n<\/ul>\n<h4>1.3 \u547d\u540d\u7a7a\u95f4\u7684\u4f7f\u7528<\/h4>\n<p>\u7f16\u8bd1\u67e5\u627e\u2f00\u4e2a\u53d8\u91cf\u7684\u58f0\u660e\/\u5b9a\u4e49\u65f6&#xff0c;\u9ed8\u8ba4\u53ea\u4f1a\u5728\u5c40\u90e8\u6216\u8005\u5168\u5c40\u67e5\u627e&#xff0c;\u4e0d\u4f1a\u5230\u547d\u540d\u7a7a\u95f4\u2fa5\u2faf\u53bb\u67e5\u627e\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e09\u79cd\u65b9\u5f0f\u53bb\u8bbf\u95ee<\/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;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">namespace<\/span> Tian<span class=\"token punctuation\">{<\/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 punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">int<\/span> main<span class=\"token punctuation\">{<\/span><br \/>\n   <span class=\"token comment\">\/\/\u7f16\u8bd1\u62a5\u9519 a&#xff1a;\u672a\u58f0\u660e\u6807\u8bc6\u7b26<\/span><br \/>\n   <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> a<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>   <span class=\"token comment\">\/\/\u6307\u5b9a\u547d\u540d\u7a7a\u95f4\u8bbf\u95ee<\/span><br \/>\n   <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> Tian<span class=\"token double-colon punctuation\">::<\/span>a<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>   <span class=\"token comment\">\/\/using\u5c06\u547d\u540d\u7a7a\u95f4\u4e2d\u67d0\u4e2a\u6210\u5458\u5c55\u5f00&#xff0c;\u9879\u2f6c\u4e2d\u7ecf\u5e38\u8bbf\u95ee\u7684\u4e0d\u5b58\u5728\u51b2\u7a81\u7684\u6210\u5458\u63a8\u8350\u8fd9\u79cd\u2f45\u5f0f<\/span><br \/>\n   <span class=\"token keyword\">using<\/span> Tian<span class=\"token double-colon punctuation\">::<\/span>a<span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> a<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>   <span class=\"token comment\">\/\/\u5c55\u5f00\u547d\u540d\u7a7a\u95f4\u4e2d\u5168\u90e8\u6210\u5458(\u51b2\u7a81\u2edb\u9669\u5f88\u2f24)<\/span><br \/>\n   <span class=\"token keyword\">using<\/span> <span class=\"token keyword\">namespace<\/span> Tian<span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> a<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/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<h3>\u4e8c\u3001C&#043;&#043;\u8f93\u5165&amp;\u8f93\u51fa<\/h3>\n<ul>\n<li>\u662fInputOutputStream\u7684\u7f29\u5199&#xff0c;\u662f\u6807\u51c6\u7684\u8f93\u5165\u3001\u8f93\u51fa\u6d41\u5e93&#xff0c;\u5b9a\u4e49\u4e86\u6807\u51c6\u7684\u8f93\u5165\u3001\u8f93 \u51fa\u5bf9\u8c61\u3002<\/li>\n<li>cout\/cin\/endl\u7b49\u90fd\u5c5e\u4e8eC&#043;&#043;\u6807\u51c6\u5e93&#xff0c;C&#043;&#043;\u6807\u51c6\u5e93\u90fd\u653e\u5728\u2f00\u4e2a\u53ebstd(standard)\u7684\u547d\u540d\u7a7a\u95f4\u4e2d&#xff0c;\u6240\u4ee5\u8981 \u901a\u8fc7\u547d\u540d\u7a7a\u95f4\u7684\u4f7f\u7528\u65b9\u5f0f\u53bb\u7528\u4ed6\u4eec\u3002<\/li>\n<li>std::cin \u662fistream\u7c7b\u7684\u5bf9\u8c61&#xff0c;\u5b83\u4e3b\u8981\u2faf\u5411\u7a84\u5b57\u7b26&#xff08;narrowcharacters(oftypechar)&#xff09;\u7684\u6807\u51c6\u8f93 \u5165\u6d41\u3002<\/li>\n<li>std::cout \u662fostream\u7c7b\u7684\u5bf9\u8c61&#xff0c;\u5b83\u4e3b\u8981\u2faf\u5411\u7a84\u5b57\u7b26\u7684\u6807\u51c6\u8f93\u51fa\u6d41\u3002<\/li>\n<li>std::endl \u662f\u4e00\u4e2a\u51fd\u6570&#xff0c;\u6d41\u63d2\u2f0a\u8f93\u51fa\u65f6&#xff0c;\u76f8\u5f53\u4e8e\u63d2\u5165\u2f00\u4e2a\u6362\u2f8f\u5b57\u7b26\u52a0\u5237\u65b0\u7f13\u51b2\u533a\u3002<\/li>\n<li>&lt;&lt;\u662f\u6d41\u63d2\u5165\u8fd0\u7b97\u7b26&#xff0c;&gt;&gt;\u662f\u6d41\u63d0\u53d6\u8fd0\u7b97\u7b26\u3002&#xff08;C\u8bed\u8a00\u8fd8\u7528\u8fd9\u4e24\u4e2a\u8fd0\u7b97\u7b26\u505a\u4f4d\u8fd0\u7b97\u5de6\u79fb\/\u53f3\u79fb&#xff09;\u3002<\/li>\n<li>\u4f7f\u7528C&#043;&#043;\u8f93\u5165\u8f93\u51fa\u66f4\u65b9\u4fbf&#xff0c;\u4e0d\u9700\u8981\u50cfprintf\/scanf\u8f93\u5165\u8f93\u51fa\u65f6\u90a3\u6837&#xff0c;\u9700\u8981\u624b\u52a8\u6307\u5b9a\u683c\u5f0f&#xff0c;C&#043;&#043;\u7684\u8f93\u5165 \u8f93\u51fa\u53ef\u4ee5\u81ea\u52a8\u8bc6\u522b\u53d8\u91cf\u7c7b\u578b&#xff0c;C&#043;&#043;\u7684\u6d41\u80fd\u66f4\u597d\u7684\u652f\u6301\u81ea\u5b9a\u4e49\u7c7b\u578b\u5bf9\u8c61\u7684\u8f93\u5165\u8f93\u51fa\u3002<\/li>\n<li>\u2f00\u822c\u65e5\u5e38\u7ec3\u4e60\u4e2d\u6211\u4eec\u53ef\u4ee5using namespace std&#xff0c;\u5b9e\u9645\u9879\u76ee\u5f00\u53d1\u4e2d\u4e0d\u5efa\u8baeusing namespace std<\/li>\n<\/ul>\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><br \/>\n<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> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token keyword\">double<\/span> b <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0.1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token keyword\">char<\/span> c <span class=\"token operator\">&#061;<\/span> <span class=\"token char\">&#039;x&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n   cout <span class=\"token operator\">&lt;&lt;<\/span> a <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034; &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> b <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;  &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> c <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token comment\">\/\/ \u53ef\u4ee5\u2f83\u52a8\u8bc6\u522b\u53d8\u91cf\u7684\u7c7b\u578b<\/span><br \/>\n   cin <span class=\"token operator\">&gt;&gt;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n   cin <span class=\"token operator\">&gt;&gt;<\/span> b <span class=\"token operator\">&gt;&gt;<\/span> c<span class=\"token punctuation\">;<\/span><br \/>\n   cout <span class=\"token operator\">&lt;&lt;<\/span> a <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n   cout <span class=\"token operator\">&lt;&lt;<\/span> b <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;  &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> c <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span>&#xff1b;<br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260803230835-6a711f734af03.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u5728io\u9700\u6c42\u6bd4\u8f83\u9ad8\u7684\u5730\u65b9&#xff0c;\u5982\u90e8\u5206\u5927\u91cf\u8f93\u5165\u7684\u7ade\u8d5b\u9898\u4e2d&#xff0c;\u52a0\u4e0a\u4ee5\u4e0b3\u884c\u4ee3\u7801\u53ef\u4ee5\u63d0\u9ad8C&#043;&#043;IO\u6548\u7387<\/p>\n<p>ios_base<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">sync_with_stdio<\/span><span class=\"token punctuation\">(<\/span><span class=\"token boolean\">false<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\ncin<span class=\"token punctuation\">.<\/span><span class=\"token function\">tie<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">nullptr<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\ncout<span class=\"token punctuation\">.<\/span><span class=\"token function\">tie<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">nullptr<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h3>\u4e09\u3001\u7f3a\u7701\u53c2\u6570<\/h3>\n<ul>\n<li>\u7f3a\u7701\u53c2\u6570\u662f\u58f0\u660e\u6216\u5b9a\u4e49\u51fd\u6570\u65f6\u4e3a\u51fd\u6570\u7684\u53c2\u6570\u6307\u5b9a\u2f00\u4e2a\u7f3a\u7701\u503c\u3002\u5728\u8c03\u7528\u8be5\u51fd\u6570\u65f6&#xff0c;\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u5b9e\u53c2 \u5219\u91c7\u7528\u8be5\u5f62\u53c2\u7684\u7f3a\u7701\u503c&#xff0c;\u5426\u5219\u4f7f\u2f64\u6307\u5b9a\u7684\u5b9e\u53c2&#xff0c;\u7f3a\u7701\u53c2\u6570\u5206\u4e3a\u5168\u7f3a\u7701\u548c\u534a\u7f3a\u7701\u53c2\u6570<\/li>\n<li>\u5168\u7f3a\u7701\u5c31\u662f\u5168\u90e8\u5f62\u53c2\u7ed9\u7f3a\u7701\u503c&#xff0c;\u534a\u7f3a\u7701\u5c31\u662f\u90e8\u5206\u5f62\u53c2\u7ed9\u7f3a\u7701\u503c\u3002C&#043;&#043;\u89c4\u5b9a\u534a\u7f3a\u7701\u53c2\u6570\u5fc5\u987b\u4ece\u53f3\u5f80\u5de6 \u4f9d\u6b21\u8fde\u7eed\u7f3a\u7701&#xff0c;\u4e0d\u80fd\u95f4\u9694\u8df3\u8dc3\u7ed9\u7f3a\u7701\u503c\u3002<\/li>\n<li>\u5e26\u7f3a\u7701\u53c2\u6570\u7684\u51fd\u6570\u8c03\u7528&#xff0c;C&#043;&#043;\u89c4\u5b9a\u5fc5\u987b\u4ece\u5de6\u5230\u53f3\u4f9d\u6b21\u7ed9\u5b9e\u53c2&#xff0c;\u4e0d\u80fd\u8df3\u8dc3\u7ed9\u5b9e\u53c2\u3002<\/li>\n<li>\u505a\u9879\u76ee\u65f6\u51fd\u6570\u58f0\u660e\u548c\u5b9a\u4e49\u5206\u79bb\u65f6&#xff0c;\u7f3a\u7701\u53c2\u6570\u4e0d\u80fd\u5728\u51fd\u6570\u58f0\u660e\u548c\u5b9a\u4e49\u4e2d\u540c\u65f6\u51fa\u73b0&#xff0c;\u89c4\u5b9a\u5fc5\u987b\u51fd\u6570\u58f0\u660e\u7ed9\u7f3a\u7701\u503c\u3002<\/li>\n<\/ul>\n<p>\u7f3a\u53c2\u4f7f\u7528\u793a\u4f8b<\/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><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">Func<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span><br \/>\n   cout <span class=\"token operator\">&lt;&lt;<\/span> a <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 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\">\/\/ \u6ca1\u6709\u4f20\u53c2\u65f6&#xff0c;\u4f7f\u2f64\u53c2\u6570\u7684\u9ed8\u8ba4\u503c<\/span><br \/>\n   <span class=\"token function\">Func<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>     <span class=\"token comment\">\/\/\u8f93\u51fa0<\/span><br \/>\n   <span class=\"token comment\">\/\/\u4f20\u53c2\u65f6&#xff0c;\u4f7f\u2f64\u6307\u5b9a\u7684\u5b9e\u53c2<\/span><br \/>\n   <span class=\"token function\">Func<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/\u8f93\u51fa10<\/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<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><br \/>\n<span class=\"token comment\">\/\/ \u5168\u7f3a\u7701 <\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">Func1<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">20<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> c <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">30<\/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;a &#061; &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> a <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n   cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;b &#061; &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> b <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n   cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;c &#061; &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> c <span class=\"token operator\">&lt;&lt;<\/span> endl <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\">\/\/ \u534a\u7f3a\u7701<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">Func2<\/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 operator\">&#061;<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">,<\/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><span class=\"token punctuation\">{<\/span><br \/>\n   cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;a &#061; &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> a <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n   cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;b &#061; &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> b <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n   cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;c &#061; &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> c <span class=\"token operator\">&lt;&lt;<\/span> endl <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> main<span class=\"token punctuation\">{<\/span><br \/>\n   <span class=\"token function\">Func1<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>     <span class=\"token comment\">\/\/10&#043;20&#043;30 &#061; 60<\/span><br \/>\n   <span class=\"token function\">Func1<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/1&#043;20&#043;30 &#061; 51<\/span><br \/>\n   <span class=\"token function\">Func1<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/1&#043;2&#043;30 &#061; 33<\/span><br \/>\n   <span class=\"token function\">Func1<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/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 punctuation\">;<\/span><span class=\"token comment\">\/\/1&#043;2&#043;3 &#061; 6<\/span><br \/>\n   <span class=\"token function\">Func2<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">100<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/100&#043;10&#043;20 &#061; 130<\/span><br \/>\n   <span class=\"token function\">Func2<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">100<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">200<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/100&#043;200&#043;20 &#061; 320<\/span><br \/>\n   <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span>&#xff1b;<br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h3>\u56db\u3001\u51fd\u6570\u91cd\u8f7d<\/h3>\n<p>C&#043;&#043;\u652f\u6301\u5728\u540c\u2f00\u4f5c\u7528\u57df\u4e2d\u51fa\u73b0\u540c\u540d\u51fd\u6570&#xff0c;\u4f46\u662f\u8981\u6c42\u8fd9\u4e9b\u540c\u540d\u51fd\u6570\u7684\u5f62\u53c2\u4e0d\u540c&#xff08;\u53c2\u6570\u4e2a\u6570\u4e0d\u540c\u6216\u8005 \u7c7b\u578b\u4e0d\u540c&#xff09;\u3002\u8fd9\u6837C&#043;&#043;\u51fd\u6570\u8c03\u7528\u5c31\u8868\u73b0\u51fa\u4e86\u591a\u6001\u884c\u4e3a&#xff0c;\u4f7f\u7528\u66f4\u7075\u6d3b\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><br \/>\n<span class=\"token comment\">\/\/\u53c2\u6570\u7c7b\u578b\u4e0d\u540c<\/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> left<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> right<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;int Add(int left, int right)&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token keyword\">return<\/span> left <span class=\"token operator\">&#043;<\/span> right<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">double<\/span> <span class=\"token function\">Add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">double<\/span> left<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">double<\/span> right<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;double Add(double left, double right)&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n   <span class=\"token keyword\">return<\/span> left <span class=\"token operator\">&#043;<\/span> right<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\">\/\/\u53c2\u6570\u4e2a\u6570\u4e0d\u540c<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">f<\/span><span class=\"token punctuation\">(<\/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;f()&#034;<\/span> <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 keyword\">void<\/span> <span class=\"token function\">f<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<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;f(int a)&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u53c2\u6570\u7c7b\u578b\u987a\u5e8f\u4e0d\u540c<\/span><br \/>\n <span class=\"token keyword\">void<\/span> <span class=\"token function\">f<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span> b<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;f(int a,char b)&#034;<\/span> <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 keyword\">void<\/span> <span class=\"token function\">f<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">char<\/span> b<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> a<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;f(char b, int a)&#034;<\/span> <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\">\/\/ \u8fd4\u56de\u503c\u4e0d\u540c\u4e0d\u80fd\u4f5c\u4e3a\u91cd\u8f7d\u6761\u4ef6&#xff0c;\u56e0\u4e3a\u8c03\u2f64\u65f6\u4e5f\u2f46\u6cd5\u533a\u5206<\/span><br \/>\n<span class=\"token comment\">\/\/void fxx()<\/span><br \/>\n<span class=\"token comment\">\/\/{}<\/span><br \/>\n<span class=\"token comment\">\/\/<\/span><br \/>\n<span class=\"token comment\">\/\/int fxx()<\/span><br \/>\n<span class=\"token comment\">\/\/{<\/span><br \/>\n<span class=\"token comment\">\/\/        <\/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 comment\">\/\/}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u4e0b\u2faf\u4e24\u4e2a\u51fd\u6570\u6784\u6210\u91cd\u8f7d<\/span><br \/>\n<span class=\"token comment\">\/\/ \u4f46\u662ff1()\u8c03\u2f64\u65f6&#xff0c;\u4f1a\u62a5\u9519&#xff0c;\u5b58\u5728\u6b67\u4e49&#xff0c;\u65e2\u53ef\u4ee5\u5339\u914d\u65e0\u53c2\u7684f1()&#xff0c;\u4e5f\u80fd\u5339\u914d\u5e26\u9ed8\u8ba4\u53c2\u6570\u7684f1(int a&#061;10)&#xff08;<\/span><\/p>\n<p><span class=\"token comment\">\/\/void f1(){<\/span><br \/>\n<span class=\"token comment\">\/\/   cout &lt;&lt; &#034;f1()&#034; &lt;&lt; endl;<\/span><br \/>\n<span class=\"token comment\">\/\/}<\/span><br \/>\n<span class=\"token comment\">\/\/void f1(int a &#061; 10&#xff09;{<\/span><br \/>\n<span class=\"token comment\">\/\/   cout &lt;&lt; &#034;f1(int a)&#034; &lt;&lt; endl;<\/span><br \/>\n<span class=\"token comment\">\/\/}<\/span><\/p>\n<h3>\u4e94\u3001\u5f15\u7528<\/h3>\n<p>\u5f15\u2f64\u4e0d\u662f\u65b0\u5b9a\u4e49\u2f00\u4e2a\u53d8\u91cf&#xff0c;\u800c\u662f\u7ed9\u5df2\u5b58\u5728\u53d8\u91cf\u53d6\u4e86\u4e00\u4e2a\u522b\u540d&#xff0c;\u7f16\u8bd1\u5668\u4e0d\u4f1a\u4e3a\u5f15\u2f64\u53d8\u91cf\u5f00\u8f9f\u5185\u5b58\u7a7a\u95f4&#xff0c;\u5b83\u548c\u5b83\u5f15\u2f64\u7684\u53d8\u91cf\u5171\u2f64\u540c\u2f00\u5757\u5185\u5b58\u7a7a\u95f4\u3002\u6bd4\u00b7\u5982&#xff1a;\u674e\u9035&#xff0c;\u6c5f\u6e56\u4e0a\u4eba\u79f0&#034;\u9ed1\u65cb\u98ce&#034;&#xff1b;\u6797\u51b2&#xff0c;\u5916\u53f7\u8c79\u2f26\u5934 \u7c7b\u578b&amp; \u5f15\u7528\u522b\u540d&#061;\u5f15\u7528\u5bf9\u8c61;<\/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> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/bc\u90fd\u662fa\u7684\u522b\u540d<\/span><br \/>\n<span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> b <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> c <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/\u4e5f\u53ef\u4ee5\u7ed9\u522b\u540db\u53d6\u522b\u540d&#xff0c;d\u76f8\u5f53\u4e8e\u8fd8\u662fa\u7684\u522b\u540d<\/span><br \/>\n<span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> d <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token operator\">&#043;&#043;<\/span>d<span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/a&#043;&#043;<\/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<h4>5.1 \u5f15\u7528\u7684\u7279\u6027<\/h4>\n<ul>\n<li>\u5f15\u7528\u5728\u5b9a\u4e49\u65f6\u5fc5\u987b\u521d\u59cb\u5316<\/li>\n<li>\u5f15\u7528\u7ed1\u5b9a\u7684\u5bf9\u8c61\u4e0d\u80fd\u6362<\/li>\n<\/ul>\n<p>  <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\">int<\/span><span class=\"token operator\">&amp;<\/span> b <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n  <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  b <span class=\"token operator\">&#061;<\/span> c<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u8fd9\u2fa5\u5e76\u2fae\u8ba9b\u5f15\u2f64c&#xff0c;\u56e0\u4e3aC&#043;&#043;\u5f15\u2f64\u4e0d\u80fd\u6539\u53d8\u6307\u5411&#xff0c;<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u8fd9\u2fa5\u662f\u2f00\u4e2a\u8d4b\u503c<\/span><br \/>\n  cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token operator\">&amp;<\/span>a <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n  cout <span class=\"token operator\">&lt;&lt;<\/span> a <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n  cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token operator\">&amp;<\/span>b <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><br \/>\n  cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token operator\">&amp;<\/span>c <span class=\"token operator\">&lt;&lt;<\/span> endl<span class=\"token punctuation\">;<\/span><\/p>\n<p>b\u3001c\u5f15\u7528\u7684\u5bf9\u8c61\u5730\u5740\u4e00\u6837&#xff0c;\u5373\u7ed1\u5b9a\u5bf9\u8c61\u4e00\u6837 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260803230835-6a711f735fa13.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>5.2 \u5f15\u7528\u7684\u4f7f\u7528<\/h4>\n<p>\u5f15\u2f64\u5728\u5b9e\u8df5\u4e2d\u4e3b\u8981\u662f\u7528\u00b7\u4e8e\u5f15\u7528\u4f20\u53c2\u548c\u5f15\u7528\u505a\u8fd4\u56de\u503c\u4e2d\u51cf\u5c11\u62f7\u8d1d\u63d0\u9ad8\u6548\u7387\u548c\u6539\u53d8\u5f15\u2f64\u5bf9\u8c61\u65f6\u540c\u65f6g\u6539\u53d8\u88ab\u5f15\u7528\u5bf9\u8c61\u3002<\/p>\n<p>\u7528\u5f15\u7528\u6765\u5b9e\u73b0\u4ea4\u6362\u51fd\u6570&#xff0c;\u53ef\u4ee5\u51cf\u5c11\u5730\u5740\u62f7\u8d1d&#xff0c;\u8bed\u6cd5\u66f4\u7b80\u6d01<\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">Swap<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> rx<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> ry<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">int<\/span> tmp <span class=\"token operator\">&#061;<\/span> rx<span class=\"token punctuation\">;<\/span><br \/>\n  rx <span class=\"token operator\">&#061;<\/span> ry<span class=\"token punctuation\">;<\/span><br \/>\n  ry <span class=\"token operator\">&#061;<\/span> tmp<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u91ccret \u662f\u51fd\u6570\u5c40\u90e8\u53d8\u91cf&#xff0c;\u51fd\u6570\u8fd0\u884c\u7ed3\u675f\u540e\u4f1a\u9500\u6bc1\u3002 return ret \u65f6&#xff1a;\u4f1a\u628a ret \u7684\u503c\u62f7\u8d1d\u4e00\u4efd\u5230\u4e34\u65f6\u53d8\u91cf&#xff0c;\u653e\u5230\u5bc4\u5b58\u5668\u91cc&#xff0c;\u518d\u628a\u4e34\u65f6\u53d8\u91cf\u7684\u503c\u8d4b\u503c\u7ed9\u5916\u9762\u7684x\u3002 \u7f3a\u70b9&#xff1a;\u4ea7\u751f\u62f7\u8d1d&#xff0c;\u5927\u5bf9\u8c61\u65f6\u5f00\u9500\u5927<\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">func<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> ret <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> ret<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">int<\/span> x <span class=\"token operator\">&#061;<\/span><span class=\"token function\">func<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u7531\u6b64\u53ef\u4ee5\u660e\u767d\u987a\u5e8f\u8868\u627e\u4e0b\u8868\u7684\u65b9\u6cd5&#xff0c;\u662f\u5c06\u6570\u7ec4\u5bf9\u5e94\u4e0b\u6807\u7684\u503c\u62f7\u8d1d\u5230\u4e34\u65f6\u53d8\u91cf\u91cc\u8fd4\u56de&#xff0c;\u540c\u65f6\u4e5f\u65e0\u6cd5\u4fee\u6539\u8fd9\u4e2a\u4e34\u65f6\u53d8\u91cf\u7684\u503c&#xff0c;\u56e0\u4e3a\u8fd9\u4e2a\u4e34\u65f6\u53d8\u91cf \u662f\u7eaf\u53f3\u503c&#xff0c;\u8bed\u6cd5\u89c4\u5b9a\u53f3\u503c\u4e0d\u80fd\u4f5c\u4e3a\u8d4b\u503c\u5de6\u64cd\u4f5c\u6570<\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">SLAt<\/span><span class=\"token punctuation\">(<\/span>SL<span class=\"token operator\">&amp;<\/span> sl<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> i<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> sl<span class=\"token punctuation\">.<\/span>a<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u62f7\u8d1d\u5143\u7d20\u5230\u4e34\u65f6\u53d8\u91cf&#xff0c;\u4ea7\u751f\u526f\u672c<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function\">SLAt<\/span><span class=\"token punctuation\">(<\/span>sl<span class=\"token punctuation\">,<\/span>i<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/\u8fd9\u4e2a\u7f16\u8bd1\u4f1a\u62a5\u9519&#xff0c;\u5de6\u64cd\u4f5c\u6570\u8981\u662f\u5de6\u503c<\/span><\/p>\n<p>\u4fee\u6539\u540e&#xff0c;return sl. a[i],\u53ef\u4ee5\u7406\u89e3\u4e3a\u7528\u4e00\u4e2a\u4e34\u65f6\u5f15\u7528\u53d8\u91cf int&amp; tmp &#061; sl. a[i]&#xff08;\u7f16\u8bd1\u5668\u4e0d\u4f1a\u771f\u7684\u521b\u5efa\u4e00\u4e2a\u540d\u53eb tmp \u7684\u53d8\u91cf&#xff0c;\u53ea\u662f\u903b\u8f91\u7b49\u4ef7&#xff09;&#xff0c;\u8fd4\u56de\u7684\u662f\u8fd4\u56de\u5bf9\u8c61\u7684\u522b\u540d&#xff0c;\u8fd9\u6837\u5c31\u53ef\u4ee5\u5bf9\u6570\u7ec4\u7684\u6570\u8fdb\u884c\u4fee\u6539<\/p>\n<p><span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> <span class=\"token function\">SLAt<\/span><span class=\"token punctuation\">(<\/span>SL<span class=\"token operator\">&amp;<\/span> sl<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> i<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> sl<span class=\"token punctuation\">.<\/span>a<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function\">SLAt<\/span><span class=\"token punctuation\">(<\/span>sl<span class=\"token punctuation\">,<\/span>i<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6ce8\u610f&#xff1a;func&#xff08;&#xff09;\u90a3\u91cc\u4e0d\u80fd\u628a\u8fd4\u56de\u503cint\u53d8\u6210int&amp;&#xff0c;\u56e0\u4e3aret\u662f\u51fd\u6570\u5c40\u90e8\u53d8\u91cf&#xff0c;\u8fd4\u56de\u4ed6\u7684\u5f15\u7528\u65f6&#xff0c;ret\u7a7a\u95f4\u5df2\u7ecf\u88ab\u9500\u6bc1\u4e86&#xff0c;\u672c\u8d28\u662f\u4e00\u79cd\u7c7b\u4f3c\u91ce\u6307\u9488\u7684\u884c\u4e3a <\/p>\n<h4>5.3 \u6307\u9488\u4e0e\u5f15\u7528\u7684\u5173\u7cfb<\/h4>\n<p>C&#043;&#043;\u4e2d\u6307\u9488\u548c\u5f15\u7528\u5728\u5b9e\u8df5\u4e2d\u4ed6\u4eec\u76f8\u8f85\u76f8\u6210,\u529f\u80fd\u6709\u91cd\u53e0\u6027&#xff0c;\u4f46\u662f\u5404\u6709\u81ea\u5df1\u7684\u7279\u70b9&#xff0c;\u4e92\u76f8\u4e0d\u53ef\u66ff\u4ee3\u3002<\/p>\n<ul>\n<li>\u8bed\u6cd5\u6982\u5ff5\u4e0a&#xff1a;\u5f15\u7528\u662f\u2f00\u4e2a\u53d8\u91cf\u7684\u53d6\u522b\u540d&#xff0c;\u4e0d\u5f00\u7a7a\u95f4&#xff1b;\u800c\u6307\u9488\u662f\u5b58\u50a8\u2f00\u4e2a\u53d8\u91cf\u5730\u5740&#xff0c;\u8981\u5f00\u7a7a\u95f4\u3002<\/li>\n<li>\u5f15\u7528\u5728\u5b9a\u4e49\u65f6\u5fc5\u987b\u521d\u59cb\u5316&#xff0c;\u6307\u9488\u5efa\u8bae\u521d\u59cb\u5316&#xff0c;\u4f46\u662f\u8bed\u6cd5\u4e0a\u4e0d\u662f\u5fc5\u987b\u7684\u3002<\/li>\n<li>\u5f15\u7528\u5728\u521d\u59cb\u5316\u65f6\u7ed1\u5b9a\u4e00\u4e2a\u5bf9\u8c61\u540e&#xff0c;\u5c31\u4e0d\u80fd\u518d\u7ed1\u5b9a\u5176\u4ed6\u7684\u5bf9\u8c61\u4e86&#xff1b;\u800c\u6307\u9488\u53ef\u4ee5\u4e0d\u65ad\u5730\u6539\u53d8\u6307\u5411\u5bf9\u8c61\u3002<\/li>\n<li>\u5f15\u7528\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u6307\u5411\u5bf9\u8c61&#xff0c;\u6307\u9488\u9700\u8981\u89e3\u5f15\u2f64\u624d\u662f\u8bbf\u95ee\u6307\u5411\u5bf9\u8c61\u3002<\/li>\n<li>\u6307\u9488\u5bb9\u6613\u51fa\u73b0\u7a7a\u6307\u9488\u6216\u8005\u91ce\u6307\u9488&#xff0c;\u800c\u5f15\u7528\u4e00\u822c\u4e0d\u4f1a&#xff0c;\u56e0\u6b64\u5f15\u7528\u4f7f\u7528\u8d77\u6765\u66f4\u5b89\u5168\u4e00\u4e9b\u3002<\/li>\n<li>sizeof(\u5f15\u7528)&#xff1a;\u5f97\u5230\u7684\u662f\u539f\u6570\u636e\u7c7b\u578b\u672c\u8eab\u7684\u5927\u5c0f&#xff0c;\u4f46sizeof&#xff08;\u6307\u9488&#xff09;\u59cb\u7ec8\u662f\u5730\u5740\u7a7a\u95f4\u6240\u5360\u5b57\u8282\u4e2a\u6570(32\u4f4d\u5e73\u53f0\u4e0b\u53604byte&#xff0c;64\u4f4d\u4e0b\u662f8byte)\u3002 <\/li>\n<\/ul>\n<h3>\u516d\u3001 const\u5f15\u7528<\/h3>\n<ul>\n<li>\u5728C&#043;&#043;\u4e2d\u5bf9\u8c61\u7684\u8bbf\u95ee\u6743\u9650\u5728\u5f15\u7528\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u7f29\u5c0f&#xff0c;\u4f46\u662f\u4e0d\u80fd\u653e\u5927<\/li>\n<\/ul>\n<p><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span> a <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ a\u662f\u5e38\u91cf&#xff0c;\u53ea\u8bfb&#xff0c;\u4e0d\u80fd\u4fee\u6539<\/span><br \/>\n<span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> r1 <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span>      <span class=\"token comment\">\/\/ \u62a5\u9519&#xff01;\u666e\u901a\u5f15\u7528\u4f1a\u4fee\u6539\u6743\u9650&#xff0c;\u6743\u9650\u653e\u5927&#xff0c;\u7981\u6b62<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> r2 <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/ \u5408\u6cd5&#xff0c;const\u5f15\u7528\u53ea\u8bfb&#xff0c;\u6743\u9650\u5339\u914d<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> b <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">20<\/span><span class=\"token punctuation\">;<\/span>            <span class=\"token comment\">\/\/ b\u65e2\u53ef\u8bfb&#xff0c;\u4e5f\u53ef\u5199<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> r <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span>      <span class=\"token comment\">\/\/ \u5408\u6cd5&#xff0c;\u6743\u9650\u53ef\u4ee5\u7f29\u5c0f<\/span><br \/>\nr <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span>               <span class=\"token comment\">\/\/ \u62a5\u9519&#xff1a;r\u662fconst\u5f15\u7528&#xff0c;\u53ea\u8bfb<\/span><br \/>\nb <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span>               <span class=\"token comment\">\/\/ \u5408\u6cd5&#xff1a;\u539f\u53d8\u91cf\u672c\u8eab\u4f9d\u65e7\u80fd\u6539<\/span><\/p>\n<ul>\n<li>int&amp; rb &#061; a*3; double d &#061; 12 .34 ; int&amp; rd &#061; d ; a*3\u7684\u7ed3\u679c\u4fdd\u5b58\u5728\u2f00\u4e2a\u4e34\u65f6\u5bf9\u8c61\u4e2d&#xff0c;int&amp; rd &#061; d \u4e5f\u662f\u7c7b\u4f3c&#xff0c;\u5728\u7c7b\u578b\u8f6c\u6362\u4e2d\u4f1a\u4ea7\u751f\u4e34\u65f6\u5bf9\u8c61\u5b58\u50a8\u4e2d\u95f4\u503c&#xff0c;\u4e5f\u5c31\u662f\u8bf4 rb\u548crd\u5f15\u7528\u7684\u90fd\u662f\u4e34\u65f6\u5bf9\u8c61&#xff0c;\u800cC&#043;&#043;\u89c4\u5b9a\u4e34\u65f6\u5bf9\u8c61\u5177\u6709\u5e38\u6027&#xff0c;\u6240\u4ee5\u8fd9\u91cc\u5c31\u89e6\u53d1\u4e86\u6743\u9650\u653e\u5927&#xff0c;\u5fc5\u987b\u8981\u7528\u5e38\u5f15\u7528\u624d\u53ef\u4ee5\u3002<\/li>\n<li>\u6240\u8c13\u4e34\u65f6\u5bf9\u8c61\u5c31\u662f\u7f16\u8bd1\u5668\u9700\u8981\u2f00\u4e2a\u7a7a\u95f4\u6682\u5b58\u8868\u8fbe\u5f0f\u7684\u6c42\u503c\u7ed3\u679c\u65f6\u4e34\u65f6\u521b\u5efa\u7684\u4e00\u4e2a\u672a\u547d\u540d\u7684\u5bf9\u8c61&#xff0c;C&#043;&#043;\u4e2d\u628a\u8fd9\u4e2a\u672a\u547d\u540d\u5bf9\u8c61\u53eb\u505a\u4e34\u65f6\u5bf9\u8c61<\/li>\n<\/ul>\n<p><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\">const<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> ra <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">30<\/span><span class=\"token punctuation\">;<\/span><br \/>\n <span class=\"token comment\">\/\/int&amp; rb &#061; a * 3;  \u7f16\u8bd1\u62a5\u9519&#xff0c;a*3\u7684\u8fd0\u7b97\u7ed3\u679c\u4f1a\u7528\u4e00\u4e2a\u4e34\u65f6\u5bf9\u8c61\u50a8\u5b58&#xff0c;\u4e0d\u80fd\u7528\u53ef\u4fee\u6539\u666e\u901a\u5f15\u7528int&amp;\u7ed1\u5b9a&#xff0c;\u56e0\u4e3a\u6743\u9650\u4e0d\u80fd\u653e\u5927<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> rb <span class=\"token operator\">&#061;<\/span> a<span class=\"token operator\">*<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/const int&amp; \u5e38\u5f15\u7528\u53ef\u4ee5\u6b63\u5e38\u7ed1\u5b9a<\/span><\/p>\n<p><span class=\"token keyword\">double<\/span> d <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">12.34<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/ int&amp; rd &#061; d;\u7f16\u8bd1\u51fa\u9519&#xff0c;\u56e0\u4e3ad \u662f double \u7c7b\u578b\u53d8\u91cf&#xff0c;\u5f15\u7528 rd \u662f int&amp;&#xff0c;\u7c7b\u578b\u4e0d\u5339\u914d&#xff0c;\u7f16\u8bd1\u5668\u4f1a\u81ea\u52a8\u9690\u5f0f\u8f6c\u6362&#xff1a;\u628a 12.34 \u622a\u65ad\u5c0f\u6570&#xff0c;\u751f\u6210\u4e34\u65f6 int \u503c 12&#xff0c;\u8fd9\u4e2a 12 \u662f\u533f\u540d\u4e34\u65f6\u5bf9\u8c61<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> rd <span class=\"token operator\">&#061;<\/span> d<span class=\"token punctuation\">;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x1f4d1; \u76ee\u5f55<br \/>\n\u4e00\u3001namespace 1.1 namespace\u7684\u4ef7\u503c1.2 namespace\u7684\u5b9a\u4e491.3 \u547d\u540d\u7a7a\u95f4\u7684\u4f7f\u7528 \u4e8c\u3001C\u8f93\u5165&amp;\u8f93\u51fa\u4e09\u3001\u7f3a\u7701\u53c2\u6570\u56db\u3001\u51fd\u6570\u91cd\u8f7d\u4e94\u3001\u5f15\u7528 5.1 \u5f15\u7528\u7684\u7279\u60275.2 \u5f15\u7528\u7684\u4f7f\u75285.3 \u6307\u9488\u4e0e\u5f15\u7528\u7684\u5173\u7cfb \u516d\u3001const\u5f15\u7528<br \/>\n\u4e00\u3001namespace 1.1 namespace\u7684\u4ef7\u503c<br \/>\n#include<br \/>\n#include<br \/>\nint rand  10;<br \/>\nint main()<br \/>\n{\/\/ \u7f16\u8bd1\u62a5\u9519<\/p>\n","protected":false},"author":2,"featured_media":89919,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10187,55,174,190],"topic":[],"class_list":["post-89921","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-codingplan","tag-c","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C \u5230 C++ \u4e1d\u6ed1\u8fc7\u6e21\u6559\u7a0b\uff08\u5165\u95e8\u57fa\u7840\u7bc7\uff09 - \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\/89921.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C \u5230 C++ \u4e1d\u6ed1\u8fc7\u6e21\u6559\u7a0b\uff08\u5165\u95e8\u57fa\u7840\u7bc7\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"&#x1f4d1; \u76ee\u5f55 \u4e00\u3001namespace 1.1 namespace\u7684\u4ef7\u503c1.2 namespace\u7684\u5b9a\u4e491.3 \u547d\u540d\u7a7a\u95f4\u7684\u4f7f\u7528 \u4e8c\u3001C\u8f93\u5165&amp;\u8f93\u51fa\u4e09\u3001\u7f3a\u7701\u53c2\u6570\u56db\u3001\u51fd\u6570\u91cd\u8f7d\u4e94\u3001\u5f15\u7528 5.1 \u5f15\u7528\u7684\u7279\u60275.2 \u5f15\u7528\u7684\u4f7f\u75285.3 \u6307\u9488\u4e0e\u5f15\u7528\u7684\u5173\u7cfb \u516d\u3001const\u5f15\u7528  \u4e00\u3001namespace 1.1 namespace\u7684\u4ef7\u503c #include #include int rand 10; int main() {\/\/ \u7f16\u8bd1\u62a5\u9519\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/89921.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-03T23:08:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260803230835-6a711f734af03.png\" \/>\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=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/89921.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/89921.html\",\"name\":\"C \u5230 C++ \u4e1d\u6ed1\u8fc7\u6e21\u6559\u7a0b\uff08\u5165\u95e8\u57fa\u7840\u7bc7\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-03T23:08:36+00:00\",\"dateModified\":\"2026-08-03T23:08:36+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/89921.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/89921.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/89921.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C \u5230 C++ \u4e1d\u6ed1\u8fc7\u6e21\u6559\u7a0b\uff08\u5165\u95e8\u57fa\u7840\u7bc7\uff09\"}]},{\"@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 \u5230 C++ \u4e1d\u6ed1\u8fc7\u6e21\u6559\u7a0b\uff08\u5165\u95e8\u57fa\u7840\u7bc7\uff09 - \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\/89921.html","og_locale":"zh_CN","og_type":"article","og_title":"C \u5230 C++ \u4e1d\u6ed1\u8fc7\u6e21\u6559\u7a0b\uff08\u5165\u95e8\u57fa\u7840\u7bc7\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"&#x1f4d1; \u76ee\u5f55 \u4e00\u3001namespace 1.1 namespace\u7684\u4ef7\u503c1.2 namespace\u7684\u5b9a\u4e491.3 \u547d\u540d\u7a7a\u95f4\u7684\u4f7f\u7528 \u4e8c\u3001C\u8f93\u5165&amp;\u8f93\u51fa\u4e09\u3001\u7f3a\u7701\u53c2\u6570\u56db\u3001\u51fd\u6570\u91cd\u8f7d\u4e94\u3001\u5f15\u7528 5.1 \u5f15\u7528\u7684\u7279\u60275.2 \u5f15\u7528\u7684\u4f7f\u75285.3 \u6307\u9488\u4e0e\u5f15\u7528\u7684\u5173\u7cfb \u516d\u3001const\u5f15\u7528  \u4e00\u3001namespace 1.1 namespace\u7684\u4ef7\u503c #include #include int rand 10; int main() {\/\/ \u7f16\u8bd1\u62a5\u9519","og_url":"https:\/\/www.wsisp.com\/helps\/89921.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-03T23:08:36+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260803230835-6a711f734af03.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/89921.html","url":"https:\/\/www.wsisp.com\/helps\/89921.html","name":"C \u5230 C++ \u4e1d\u6ed1\u8fc7\u6e21\u6559\u7a0b\uff08\u5165\u95e8\u57fa\u7840\u7bc7\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-03T23:08:36+00:00","dateModified":"2026-08-03T23:08:36+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/89921.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/89921.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/89921.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C \u5230 C++ \u4e1d\u6ed1\u8fc7\u6e21\u6559\u7a0b\uff08\u5165\u95e8\u57fa\u7840\u7bc7\uff09"}]},{"@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\/89921","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=89921"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/89921\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/89919"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=89921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=89921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=89921"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=89921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}