{"id":108351,"date":"2026-09-21T17:17:07","date_gmt":"2026-09-21T09:17:07","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/108351.html"},"modified":"2026-09-21T17:17:07","modified_gmt":"2026-09-21T09:17:07","slug":"c%e6%a8%a1%e6%9d%bf%e5%85%a5%e9%97%a8%ef%bc%9a%e4%bb%8e%e5%86%99%e4%b8%89%e9%81%8d%e4%ba%a4%e6%8d%a2%e5%87%bd%e6%95%b0%e5%88%b0%e4%b8%80%e6%ac%a1%e6%90%9e%e5%ae%9a","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/108351.html","title":{"rendered":"C++\u6a21\u677f\u5165\u95e8\uff1a\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a"},"content":{"rendered":"<h2>C&#043;&#043;\u6a21\u677f\u5165\u95e8&#xff1a;\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a<\/h2>\n<p>\u672c\u6587\u662f \u300a\u73b0\u4ee3C&#043;&#043;\u6a21\u677f\u6df1\u5ea6\u89e3\u6790\u300b \u4e13\u680f\u7684\u7b2c\u4e00\u7bc7\u3002\u6211\u4eec\u5c06\u4ece\u6700\u6734\u7d20\u7684\u4ee3\u7801\u75db\u70b9\u51fa\u53d1&#xff0c;\u4e00\u6b65\u6b65\u7406\u89e3C&#043;&#043;\u4e3a\u4ec0\u4e48\u9700\u8981\u6a21\u677f&#xff0c;\u4ee5\u53ca\u6a21\u677f\u5982\u4f55\u505a\u5230\u201c\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d\u201d\u3002<\/p>\n<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>C&#043;&#043;\u6a21\u677f\u5165\u95e8&#xff1a;\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a<\/li>\n<li>\n<ul>\n<li>\u4e00\u3001\u4ece\u4e00\u4e2a\u5c0f\u9700\u6c42\u8bf4\u8d77<\/li>\n<li>\u4e8c\u3001\u5b8f\u5b9a\u4e49\u80fd\u89e3\u51b3\u5417&#xff1f;<\/li>\n<li>\u4e09\u3001\u6a21\u677f&#xff1a;\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d<\/li>\n<li>\n<ul>\n<li>3.1 \u51fd\u6570\u6a21\u677f\u7684\u57fa\u672c\u8bed\u6cd5<\/li>\n<li>3.2 \u6a21\u677f\u7684\u5b9e\u4f8b\u5316<\/li>\n<li>3.3 \u5b8c\u6574\u53ef\u8fd0\u884c\u793a\u4f8b<\/li>\n<\/ul>\n<\/li>\n<li>\u56db\u3001\u6a21\u677f vs \u5b8f&#xff1a;\u4e3a\u4ec0\u4e48\u6a21\u677f\u66f4\u5b89\u5168<\/li>\n<li>\u4e94\u3001\u521d\u6b65\u7406\u89e3&#xff1a;\u6a21\u677f\u4e0d\u662f\u201c\u4e00\u4e2a\u51fd\u6570\u201d&#xff0c;\u800c\u662f\u201c\u4e00\u65cf\u51fd\u6570\u201d<\/li>\n<li>\u516d\u3001\u603b\u7ed3\u4e0e\u4e0b\u4e00\u7bc7\u9884\u544a<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u4e00\u3001\u4ece\u4e00\u4e2a\u5c0f\u9700\u6c42\u8bf4\u8d77<\/h3>\n<p>\u5047\u8bbe\u4f60\u6b63\u5728\u5199\u4e00\u4e2a\u5de5\u5177\u5e93&#xff0c;\u9700\u8981\u4e00\u4e2a\u4ea4\u6362\u4e24\u4e2a\u53d8\u91cf\u7684\u51fd\u6570\u3002\u8fd9\u8fd8\u4e0d\u7b80\u5355&#xff1f;\u4e09\u884c\u4ee3\u7801\u641e\u5b9a&#xff1a;<\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">swapInt<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> temp <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n    a <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n    b <span class=\"token operator\">&#061;<\/span> temp<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4f46\u5f88\u5feb&#xff0c;\u4ea7\u54c1\u7ecf\u7406\u8bf4&#xff1a;\u201cdouble \u7c7b\u578b\u4e5f\u8981\u4ea4\u6362\u3002\u201d \u4e8e\u662f\u4f60\u590d\u5236\u7c98\u8d34&#xff0c;\u6539\u4e2a\u7c7b\u578b\u540d&#xff1a;<\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">swapDouble<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">double<\/span><span class=\"token operator\">&amp;<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">double<\/span><span class=\"token operator\">&amp;<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">double<\/span> temp <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n    a <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n    b <span class=\"token operator\">&#061;<\/span> temp<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u63a5\u7740&#xff0c;std::string \u4e5f\u8981\u4ea4\u6362&#xff0c;\u81ea\u5b9a\u4e49\u7684 Student \u7c7b\u4e5f\u8981\u4ea4\u6362\u2026\u2026\u4f60\u53d1\u73b0\u81ea\u5df1\u7684\u4ee3\u7801\u91cc\u51fa\u73b0\u4e86\u5927\u91cf\u957f\u5f97\u51e0\u4e4e\u4e00\u6a21\u4e00\u6837\u7684\u51fd\u6570&#xff0c;\u552f\u4e00\u7684\u533a\u522b\u5c31\u662f\u7c7b\u578b\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u51fd\u6570\u91cd\u8f7d\u7684\u56f0\u5883&#xff1a;\u903b\u8f91\u5b8c\u5168\u76f8\u540c&#xff0c;\u5374\u8981\u4e3a\u6bcf\u79cd\u7c7b\u578b\u91cd\u590d\u7f16\u5199\u3002\u66f4\u9ebb\u70e6\u7684\u662f&#xff0c;\u5982\u679c\u67d0\u5929\u4ea4\u6362\u903b\u8f91\u9700\u8981\u4fee\u6539&#xff08;\u6bd4\u5982\u52a0\u5165\u65e5\u5fd7&#xff09;&#xff0c;\u4f60\u5f97\u628a\u6240\u6709\u91cd\u8f7d\u7248\u672c\u90fd\u6539\u4e00\u904d&#xff0c;\u6f0f\u6389\u4e00\u4e2a\u5c31\u662f\u9690\u85cf\u7684 bug\u3002<\/p>\n<h3>\u4e8c\u3001\u5b8f\u5b9a\u4e49\u80fd\u89e3\u51b3\u5417&#xff1f;<\/h3>\n<p>\u6709\u8fc7C\u8bed\u8a00\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\u4f1a\u60f3\u5230\u5b8f&#xff1a;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name function\">SWAP<\/span><span class=\"token expression\"><span class=\"token punctuation\">(<\/span>a<span class=\"token punctuation\">,<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">do<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">auto<\/span> temp <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span> a <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span> b <span class=\"token operator\">&#061;<\/span> temp<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">while<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><\/span><\/span><\/p>\n<p>\u5b8f\u786e\u5b9e\u53ef\u4ee5\u505a\u5230\u201c\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u4f7f\u7528\u201d\u3002\u4f46\u5b83\u6709\u51e0\u4e2a\u81f4\u547d\u7f3a\u9677&#xff1a;<\/p>\n<li>\u6ca1\u6709\u7c7b\u578b\u68c0\u67e5\u3002SWAP(1, 2) \u5c55\u5f00\u540e\u53d8\u6210 auto temp &#061; 1; 1 &#061; 2; 2 &#061; temp;&#xff0c;\u7f16\u8bd1\u9519\u8bef\u4fe1\u606f\u8ba9\u4eba\u6478\u4e0d\u7740\u5934\u8111\u3002<\/li>\n<li>\u65e0\u6cd5\u8c03\u8bd5\u3002\u5b8f\u5728\u9884\u5904\u7406\u9636\u6bb5\u5c31\u88ab\u66ff\u6362\u4e86&#xff0c;\u8c03\u8bd5\u5668\u770b\u4e0d\u5230 SWAP \u8fd9\u4e2a\u51fd\u6570\u3002<\/li>\n<li>\u5bb9\u6613\u4ea7\u751f\u526f\u4f5c\u7528\u3002\u5982\u679c\u53c2\u6570\u662f i&#043;&#043; \u8fd9\u6837\u7684\u8868\u8fbe\u5f0f&#xff0c;\u53ef\u80fd\u88ab\u591a\u6b21\u6c42\u503c\u3002<\/li>\n<li>\u547d\u540d\u6c61\u67d3\u3002\u5b8f\u6ca1\u6709\u4f5c\u7528\u57df\u6982\u5ff5&#xff0c;\u5bb9\u6613\u4e0e\u5176\u4ed6\u4ee3\u7801\u51b2\u7a81\u3002<\/li>\n<p>\u5b8f\u662f\u201c\u6587\u672c\u66ff\u6362\u201d&#xff0c;\u800c\u6211\u4eec\u9700\u8981\u7684\u662f\u201c\u7c7b\u578b\u5b89\u5168\u7684\u4ee3\u7801\u751f\u6210\u201d\u3002\u8fd9\u6b63\u662f\u6a21\u677f\u8981\u89e3\u51b3\u7684\u95ee\u9898\u3002<\/p>\n<h3>\u4e09\u3001\u6a21\u677f&#xff1a;\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d<\/h3>\n<p>C&#043;&#043; \u7684 \u51fd\u6570\u6a21\u677f \u5141\u8bb8\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u201c\u7c7b\u578b\u53c2\u6570\u5316\u201d\u7684\u51fd\u6570\u3002\u7f16\u8bd1\u5668\u4f1a\u6839\u636e\u8c03\u7528\u65f6\u4f20\u5165\u7684\u5b9e\u53c2\u7c7b\u578b&#xff0c;\u81ea\u52a8\u751f\u6210\u5bf9\u5e94\u7684\u51fd\u6570\u7248\u672c\u3002<\/p>\n<h4>3.1 \u51fd\u6570\u6a21\u677f\u7684\u57fa\u672c\u8bed\u6cd5<\/h4>\n<p><span class=\"token keyword\">template<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">typename<\/span> <span class=\"token class-name\">T<\/span><span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">mySwap<\/span><span class=\"token punctuation\">(<\/span>T<span class=\"token operator\">&amp;<\/span> a<span class=\"token punctuation\">,<\/span> T<span class=\"token operator\">&amp;<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    T temp <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n    a <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n    b <span class=\"token operator\">&#061;<\/span> temp<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<ul>\n<li>template&lt;typename T&gt; \u58f0\u660e\u8fd9\u662f\u4e00\u4e2a\u6a21\u677f&#xff0c;T \u662f\u7c7b\u578b\u53c2\u6570&#xff08;\u4e5f\u53ef\u4ee5\u7528 class \u4ee3\u66ff typename&#xff0c;\u4e8c\u8005\u5728\u6b64\u5904\u7b49\u4ef7&#xff09;\u3002<\/li>\n<li>T&amp; \u8868\u793a\u63a5\u53d7\u4efb\u610f\u7c7b\u578b\u7684\u5f15\u7528\u3002<\/li>\n<li>\u51fd\u6570\u4f53\u5185 T \u5c31\u50cf\u4e00\u4e2a\u666e\u901a\u7c7b\u578b\u540d&#xff0c;\u53ef\u4ee5\u58f0\u660e\u53d8\u91cf\u3001\u4f20\u9012\u53c2\u6570\u3002<\/li>\n<\/ul>\n<h4>3.2 \u6a21\u677f\u7684\u5b9e\u4f8b\u5316<\/h4>\n<p>\u5f53\u4f60\u5199\u4e0b mySwap(x, y) \u65f6&#xff0c;\u7f16\u8bd1\u5668\u4f1a\u8fdb\u884c \u6a21\u677f\u5b9e\u53c2\u63a8\u5bfc&#xff0c;\u6839\u636e x \u548c y \u7684\u7c7b\u578b\u63a8\u65ad\u51fa T \u7684\u5177\u4f53\u7c7b\u578b&#xff0c;\u7136\u540e\u751f\u6210\u4e00\u4e2a\u4e13\u95e8\u5904\u7406\u8be5\u7c7b\u578b\u7684\u51fd\u6570\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u79f0\u4e3a \u5b9e\u4f8b\u5316\u3002<\/p>\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> b <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">20<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">mySwap<\/span><span class=\"token punctuation\">(<\/span>a<span class=\"token punctuation\">,<\/span> b<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>        <span class=\"token comment\">\/\/ \u7f16\u8bd1\u5668\u751f\u6210 mySwap&lt;int&gt;(int&amp;, int&amp;)<\/span><\/p>\n<p><span class=\"token keyword\">double<\/span> c <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">3.14<\/span><span class=\"token punctuation\">,<\/span> d <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2.71<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">mySwap<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">,<\/span> d<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>        <span class=\"token comment\">\/\/ \u7f16\u8bd1\u5668\u751f\u6210 mySwap&lt;double&gt;(double&amp;, double&amp;)<\/span><\/p>\n<p>std<span class=\"token double-colon punctuation\">::<\/span>string e <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;foo&#034;<\/span><span class=\"token punctuation\">,<\/span> f <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;bar&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">mySwap<\/span><span class=\"token punctuation\">(<\/span>e<span class=\"token punctuation\">,<\/span> f<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>        <span class=\"token comment\">\/\/ \u7f16\u8bd1\u5668\u751f\u6210 mySwap&lt;std::string&gt;(std::string&amp;, std::string&amp;)<\/span><\/p>\n<p>\u6ce8\u610f&#xff1a;\u6a21\u677f\u672c\u8eab\u4e0d\u662f\u51fd\u6570&#xff0c;\u800c\u662f\u751f\u6210\u51fd\u6570\u7684\u201c\u84dd\u56fe\u201d\u3002\u53ea\u6709\u88ab\u8c03\u7528\u65f6&#xff0c;\u7f16\u8bd1\u5668\u624d\u4f1a\u6839\u636e\u5177\u4f53\u7c7b\u578b\u751f\u6210\u771f\u6b63\u7684\u51fd\u6570\u4ee3\u7801\u3002<\/p>\n<h4>3.3 \u5b8c\u6574\u53ef\u8fd0\u884c\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><\/p>\n<p><span class=\"token comment\">\/\/ \u666e\u901a\u91cd\u8f7d\u7248\u672c&#xff1a;\u6bcf\u79cd\u7c7b\u578b\u90fd\u8981\u5199\u4e00\u904d<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">swapInt<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span><span class=\"token operator\">&amp;<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> temp <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n    a <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n    b <span class=\"token operator\">&#061;<\/span> temp<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">swapDouble<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">double<\/span><span class=\"token operator\">&amp;<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">double<\/span><span class=\"token operator\">&amp;<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">double<\/span> temp <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n    a <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n    b <span class=\"token operator\">&#061;<\/span> temp<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">swapString<\/span><span class=\"token punctuation\">(<\/span>std<span class=\"token double-colon punctuation\">::<\/span>string<span class=\"token operator\">&amp;<\/span> a<span class=\"token punctuation\">,<\/span> std<span class=\"token double-colon punctuation\">::<\/span>string<span class=\"token operator\">&amp;<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>string temp <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n    a <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n    b <span class=\"token operator\">&#061;<\/span> temp<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u6a21\u677f\u7248\u672c&#xff1a;\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d<\/span><br \/>\n<span class=\"token keyword\">template<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">typename<\/span> <span class=\"token class-name\">T<\/span><span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">mySwap<\/span><span class=\"token punctuation\">(<\/span>T<span class=\"token operator\">&amp;<\/span> a<span class=\"token punctuation\">,<\/span> T<span class=\"token operator\">&amp;<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    T temp <span class=\"token operator\">&#061;<\/span> a<span class=\"token punctuation\">;<\/span><br \/>\n    a <span class=\"token operator\">&#061;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n    b <span class=\"token operator\">&#061;<\/span> temp<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 comment\">\/\/ \u4f7f\u7528\u666e\u901a\u91cd\u8f7d<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> x <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> y <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">swapInt<\/span><span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;x&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> x <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;, y&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> y <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">double<\/span> d1 <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1.1<\/span><span class=\"token punctuation\">,<\/span> d2 <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2.2<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">swapDouble<\/span><span class=\"token punctuation\">(<\/span>d1<span class=\"token punctuation\">,<\/span> d2<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;d1&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> d1 <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;, d2&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> d2 <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><\/p>\n<p>    std<span class=\"token double-colon punctuation\">::<\/span>string s1 <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;hello&#034;<\/span><span class=\"token punctuation\">,<\/span> s2 <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;world&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">swapString<\/span><span class=\"token punctuation\">(<\/span>s1<span class=\"token punctuation\">,<\/span> s2<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;s1&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> s1 <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;, s2&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> s2 <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u4f7f\u7528\u6a21\u677f<\/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> b <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">20<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">mySwap<\/span><span class=\"token punctuation\">(<\/span>a<span class=\"token punctuation\">,<\/span> b<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>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> <span class=\"token string\">&#034;, b&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> b <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">double<\/span> c <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">3.14<\/span><span class=\"token punctuation\">,<\/span> d <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2.71<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">mySwap<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">,<\/span> d<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>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> <span class=\"token string\">&#034;, d&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> d <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><\/p>\n<p>    std<span class=\"token double-colon punctuation\">::<\/span>string e <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;foo&#034;<\/span><span class=\"token punctuation\">,<\/span> f <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;bar&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">mySwap<\/span><span class=\"token punctuation\">(<\/span>e<span class=\"token punctuation\">,<\/span> f<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;e&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> e <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;, f&#061;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> f <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<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<p>\u8f93\u51fa\u7ed3\u679c&#xff1a;<\/p>\n<p>x&#061;2, y&#061;1<br \/>\nd1&#061;2.2, d2&#061;1.1<br \/>\ns1&#061;world, s2&#061;hello<br \/>\na&#061;20, b&#061;10<br \/>\nc&#061;2.71, d&#061;3.14<br \/>\ne&#061;bar, f&#061;foo<\/p>\n<p>\u53ef\u4ee5\u770b\u5230&#xff0c;\u6a21\u677f\u7248\u672c\u7684 mySwap \u7528\u4e00\u4efd\u4ee3\u7801\u5b8c\u6210\u4e86\u4e09\u79cd\u7c7b\u578b\u7684\u4ea4\u6362&#xff0c;\u800c\u4e14\u4ee3\u7801\u903b\u8f91\u6e05\u6670\u3001\u7c7b\u578b\u5b89\u5168\u3002<\/p>\n<h3>\u56db\u3001\u6a21\u677f vs \u5b8f&#xff1a;\u4e3a\u4ec0\u4e48\u6a21\u677f\u66f4\u5b89\u5168<\/h3>\n<table>\n<tr>\u7279\u6027\u5b8f\u6a21\u677f<\/tr>\n<tbody>\n<tr>\n<td>\u7c7b\u578b\u68c0\u67e5<\/td>\n<td>\u65e0<\/td>\n<td>\u6709&#xff0c;\u7f16\u8bd1\u671f\u4e25\u683c\u68c0\u67e5<\/td>\n<\/tr>\n<tr>\n<td>\u8c03\u8bd5\u652f\u6301<\/td>\n<td>\u5dee<\/td>\n<td>\u597d&#xff0c;\u53ef\u65ad\u70b9\u3001\u53ef\u5355\u6b65<\/td>\n<\/tr>\n<tr>\n<td>\u4f5c\u7528\u57df<\/td>\n<td>\u65e0&#xff0c;\u5168\u5c40\u6c61\u67d3<\/td>\n<td>\u9075\u5faaC&#043;&#043;\u4f5c\u7528\u57df\u89c4\u5219<\/td>\n<\/tr>\n<tr>\n<td>\u526f\u4f5c\u7528<\/td>\n<td>\u53ef\u80fd\u591a\u6b21\u6c42\u503c<\/td>\n<td>\u53c2\u6570\u53ea\u6c42\u503c\u4e00\u6b21<\/td>\n<\/tr>\n<tr>\n<td>\u9519\u8bef\u4fe1\u606f<\/td>\n<td>\u96be\u4ee5\u7406\u89e3<\/td>\n<td>\u76f8\u5bf9\u6e05\u6670&#xff08;C&#043;&#043;20 Concepts \u540e\u66f4\u597d&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u4ee3\u7801\u751f\u6210<\/td>\n<td>\u6587\u672c\u66ff\u6362<\/td>\n<td>\u7f16\u8bd1\u671f\u7c7b\u578b\u5b89\u5168\u7684\u4ee3\u7801\u751f\u6210<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6a21\u677f\u7684\u672c\u8d28\u662f \u7f16\u8bd1\u671f\u7684\u4ee3\u7801\u751f\u6210\u5668&#xff1a;\u4f60\u7ed9\u51fa\u903b\u8f91\u6846\u67b6&#xff0c;\u7f16\u8bd1\u5668\u6839\u636e\u5177\u4f53\u7c7b\u578b\u586b\u5145\u7ec6\u8282\u3002\u5b83\u65e2\u4fdd\u7559\u4e86\u4ee3\u7801\u590d\u7528\u7684\u4f18\u52bf&#xff0c;\u53c8\u907f\u514d\u4e86\u5b8f\u7684\u79cd\u79cd\u9677\u9631\u3002<\/p>\n<h3>\u4e94\u3001\u521d\u6b65\u7406\u89e3&#xff1a;\u6a21\u677f\u4e0d\u662f\u201c\u4e00\u4e2a\u51fd\u6570\u201d&#xff0c;\u800c\u662f\u201c\u4e00\u65cf\u51fd\u6570\u201d<\/h3>\n<p>\u5f53\u4f60\u5199\u4e0b template&lt;typename T&gt; void mySwap(T&amp;, T&amp;) \u65f6&#xff0c;\u4f60\u5e76\u6ca1\u6709\u5b9a\u4e49\u4e00\u4e2a\u5177\u4f53\u7684\u51fd\u6570&#xff0c;\u800c\u662f\u5b9a\u4e49\u4e86\u4e00\u4e2a \u51fd\u6570\u6a21\u677f\u3002\u7f16\u8bd1\u5668\u5728\u9047\u5230 mySwap(a, b) \u65f6&#xff0c;\u624d\u4f1a\u6839\u636e a\u3001b \u7684\u7c7b\u578b\u751f\u6210\u4e00\u4e2a\u5177\u4f53\u7684\u51fd\u6570\u5b9e\u4f8b\u3002<\/p>\n<p>\u8fd9\u79cd\u201c\u6309\u9700\u751f\u6210\u201d\u7684\u673a\u5236\u5e26\u6765\u4e24\u4e2a\u91cd\u8981\u7279\u6027&#xff1a;<\/p>\n<li>\u96f6\u8fd0\u884c\u65f6\u5f00\u9500&#xff1a;\u751f\u6210\u7684\u4ee3\u7801\u548c\u624b\u5199\u7684\u91cd\u8f7d\u51fd\u6570\u5b8c\u5168\u4e00\u6837&#xff0c;\u6ca1\u6709\u989d\u5916\u7684\u8fd0\u884c\u65f6\u6210\u672c\u3002<\/li>\n<li>\u7c7b\u578b\u5b89\u5168&#xff1a;\u5982\u679c\u7c7b\u578b\u4e0d\u652f\u6301\u4ea4\u6362\u64cd\u4f5c&#xff08;\u6bd4\u5982\u67d0\u4e2a\u7c7b\u7981\u7528\u4e86\u8d4b\u503c&#xff09;&#xff0c;\u7f16\u8bd1\u5668\u4f1a\u5728\u5b9e\u4f8b\u5316\u65f6\u62a5\u9519&#xff0c;\u800c\u4e0d\u662f\u50cf\u5b8f\u90a3\u6837\u4ea7\u751f\u96be\u4ee5\u7406\u89e3\u7684\u9519\u8bef\u3002<\/li>\n<h3>\u516d\u3001\u603b\u7ed3\u4e0e\u4e0b\u4e00\u7bc7\u9884\u544a<\/h3>\n<p>\u672c\u6587\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u7684\u75db\u70b9\u51fa\u53d1&#xff0c;\u4ecb\u7ecd\u4e86\u51fd\u6570\u6a21\u677f\u7684\u57fa\u672c\u8bed\u6cd5\u3001\u5b9e\u4f8b\u5316\u8fc7\u7a0b&#xff0c;\u4ee5\u53ca\u5b83\u76f8\u6bd4\u5b8f\u5b9a\u4e49\u7684\u4f18\u52bf\u3002\u6a21\u677f\u8ba9C&#043;&#043;\u5177\u5907\u4e86 \u6cdb\u578b\u7f16\u7a0b \u7684\u80fd\u529b&#xff1a;\u7528\u4e00\u4efd\u903b\u8f91\u5904\u7406\u591a\u79cd\u7c7b\u578b&#xff0c;\u540c\u65f6\u4fdd\u6301\u7c7b\u578b\u5b89\u5168\u548c\u8fd0\u884c\u6548\u7387\u3002<\/p>\n<p>\u4e0b\u4e00\u7bc7\u6211\u4eec\u5c06\u6df1\u5165 \u51fd\u6570\u6a21\u677f\u7684\u63a8\u5bfc\u89c4\u5219\u4e0e\u91cd\u8f7d\u51b3\u8bae&#xff0c;\u56de\u7b54\u51e0\u4e2a\u5173\u952e\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>f(1, 2.0) \u8fd9\u6837\u7684\u8c03\u7528&#xff0c;\u6a21\u677f\u53c2\u6570 T \u4f1a\u63a8\u5bfc\u6210\u4ec0\u4e48&#xff1f;<\/li>\n<li>\u51fd\u6570\u6a21\u677f\u548c\u666e\u901a\u51fd\u6570\u91cd\u8f7d\u540c\u65f6\u5b58\u5728\u65f6&#xff0c;\u7f16\u8bd1\u5668\u4f18\u5148\u9009\u62e9\u8c01&#xff1f;<\/li>\n<li>\u663e\u5f0f\u5b9e\u4f8b\u5316\u548c\u9690\u5f0f\u5b9e\u4f8b\u5316\u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/li>\n<\/ul>\n<p>\u656c\u8bf7\u671f\u5f85\u300a\u51fd\u6570\u6a21\u677f\u7684\u63a8\u5bfc\u89c4\u5219\u4e0e\u91cd\u8f7d\u51b3\u8bae&#xff1a;\u4e00\u6b21\u8bb2\u900f\u300b\u3002<\/p>\n<hr \/>\n<p>\u9762\u8bd5\u89c6\u89d2 \u9762\u8bd5\u5b98\u53ef\u80fd\u4f1a\u95ee&#xff1a;\u201c\u51fd\u6570\u6a21\u677f\u548c\u5b8f\u6709\u4ec0\u4e48\u533a\u522b&#xff1f;\u201d\u6216\u201c\u6a21\u677f\u4e3a\u4ec0\u4e48\u80fd\u5b9e\u73b0\u7c7b\u578b\u5b89\u5168&#xff1f;\u201d \u56de\u7b54\u65f6\u6293\u4f4f\u4e24\u70b9&#xff1a;\u7f16\u8bd1\u671f\u7c7b\u578b\u63a8\u5bfc\u4e0e\u68c0\u67e5&#xff0c;\u4ee5\u53ca\u6309\u9700\u5b9e\u4f8b\u5316\u751f\u6210\u5177\u4f53\u4ee3\u7801\u3002\u5982\u679c\u80fd\u4e3e\u51fa\u5b8f\u7684\u526f\u4f5c\u7528\u4f8b\u5b50&#xff0c;\u4f1a\u662f\u4e0d\u9519\u7684\u52a0\u5206\u9879\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C\u6a21\u677f\u5165\u95e8&#xff1a;\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a<br \/>\n\u672c\u6587\u662f \u300a\u73b0\u4ee3C\u6a21\u677f\u6df1\u5ea6\u89e3\u6790\u300b \u4e13\u680f\u7684\u7b2c\u4e00\u7bc7\u3002\u6211\u4eec\u5c06\u4ece\u6700\u6734\u7d20\u7684\u4ee3\u7801\u75db\u70b9\u51fa\u53d1&#xff0c;\u4e00\u6b65\u6b65\u7406\u89e3C\u4e3a\u4ec0\u4e48\u9700\u8981\u6a21\u677f&#xff0c;\u4ee5\u53ca\u6a21\u677f\u5982\u4f55\u505a\u5230\u201c\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d\u201d\u3002 \u6587\u7ae0\u76ee\u5f55C\u6a21\u677f\u5165\u95e8&#xff1a;\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a\u4e00\u3001\u4ece\u4e00\u4e2a\u5c0f\u9700\u6c42\u8bf4\u8d77\u4e8c\u3001\u5b8f\u5b9a\u4e49\u80fd\u89e3\u51b3\u5417&#xff1f;\u4e09\u3001\u6a21\u677f&#xff1a;\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d3.1 \u51fd\u6570\u6a21\u677f\u7684\u57fa\u672c\u8bed\u6cd53.2 \u6a21\u677f\u7684\u5b9e\u4f8b\u53163.3 <\/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,174,190,427],"topic":[],"class_list":["post-108351","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-190","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++\u6a21\u677f\u5165\u95e8\uff1a\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a - \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\/108351.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++\u6a21\u677f\u5165\u95e8\uff1a\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"C\u6a21\u677f\u5165\u95e8&#xff1a;\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a \u672c\u6587\u662f \u300a\u73b0\u4ee3C\u6a21\u677f\u6df1\u5ea6\u89e3\u6790\u300b \u4e13\u680f\u7684\u7b2c\u4e00\u7bc7\u3002\u6211\u4eec\u5c06\u4ece\u6700\u6734\u7d20\u7684\u4ee3\u7801\u75db\u70b9\u51fa\u53d1&#xff0c;\u4e00\u6b65\u6b65\u7406\u89e3C\u4e3a\u4ec0\u4e48\u9700\u8981\u6a21\u677f&#xff0c;\u4ee5\u53ca\u6a21\u677f\u5982\u4f55\u505a\u5230\u201c\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d\u201d\u3002 \u6587\u7ae0\u76ee\u5f55C\u6a21\u677f\u5165\u95e8&#xff1a;\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a\u4e00\u3001\u4ece\u4e00\u4e2a\u5c0f\u9700\u6c42\u8bf4\u8d77\u4e8c\u3001\u5b8f\u5b9a\u4e49\u80fd\u89e3\u51b3\u5417&#xff1f;\u4e09\u3001\u6a21\u677f&#xff1a;\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d3.1 \u51fd\u6570\u6a21\u677f\u7684\u57fa\u672c\u8bed\u6cd53.2 \u6a21\u677f\u7684\u5b9e\u4f8b\u53163.3\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/108351.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-21T09:17:07+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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/108351.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/108351.html\",\"name\":\"C++\u6a21\u677f\u5165\u95e8\uff1a\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-21T09:17:07+00:00\",\"dateModified\":\"2026-09-21T09:17:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/108351.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/108351.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/108351.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++\u6a21\u677f\u5165\u95e8\uff1a\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a\"}]},{\"@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++\u6a21\u677f\u5165\u95e8\uff1a\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a - \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\/108351.html","og_locale":"zh_CN","og_type":"article","og_title":"C++\u6a21\u677f\u5165\u95e8\uff1a\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"C\u6a21\u677f\u5165\u95e8&#xff1a;\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a \u672c\u6587\u662f \u300a\u73b0\u4ee3C\u6a21\u677f\u6df1\u5ea6\u89e3\u6790\u300b \u4e13\u680f\u7684\u7b2c\u4e00\u7bc7\u3002\u6211\u4eec\u5c06\u4ece\u6700\u6734\u7d20\u7684\u4ee3\u7801\u75db\u70b9\u51fa\u53d1&#xff0c;\u4e00\u6b65\u6b65\u7406\u89e3C\u4e3a\u4ec0\u4e48\u9700\u8981\u6a21\u677f&#xff0c;\u4ee5\u53ca\u6a21\u677f\u5982\u4f55\u505a\u5230\u201c\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d\u201d\u3002 \u6587\u7ae0\u76ee\u5f55C\u6a21\u677f\u5165\u95e8&#xff1a;\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a\u4e00\u3001\u4ece\u4e00\u4e2a\u5c0f\u9700\u6c42\u8bf4\u8d77\u4e8c\u3001\u5b8f\u5b9a\u4e49\u80fd\u89e3\u51b3\u5417&#xff1f;\u4e09\u3001\u6a21\u677f&#xff1a;\u4e00\u6b21\u5b9a\u4e49&#xff0c;\u591a\u7c7b\u578b\u9002\u914d3.1 \u51fd\u6570\u6a21\u677f\u7684\u57fa\u672c\u8bed\u6cd53.2 \u6a21\u677f\u7684\u5b9e\u4f8b\u53163.3","og_url":"https:\/\/www.wsisp.com\/helps\/108351.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-21T09:17:07+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/108351.html","url":"https:\/\/www.wsisp.com\/helps\/108351.html","name":"C++\u6a21\u677f\u5165\u95e8\uff1a\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-21T09:17:07+00:00","dateModified":"2026-09-21T09:17:07+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/108351.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/108351.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/108351.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C++\u6a21\u677f\u5165\u95e8\uff1a\u4ece\u201c\u5199\u4e09\u904d\u4ea4\u6362\u51fd\u6570\u201d\u5230\u4e00\u6b21\u641e\u5b9a"}]},{"@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\/108351","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=108351"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/108351\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=108351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=108351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=108351"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=108351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}