{"id":1013,"date":"2021-03-13T17:01:57","date_gmt":"2021-03-13T09:01:57","guid":{"rendered":"http:\/\/www.zyhcoding.club\/?p=1013"},"modified":"2021-03-15T17:06:04","modified_gmt":"2021-03-15T09:06:04","slug":"c-c%e8%af%ad%e6%b3%95","status":"publish","type":"post","link":"http:\/\/www.zyhcoding.club\/index.php\/2021\/03\/13\/c-c%e8%af%ad%e6%b3%95\/","title":{"rendered":"C\/C++\u8bed\u6cd5"},"content":{"rendered":"<h3>\u591a\u6001\u6027<\/h3>\n<hr \/>\n<p>&emsp;&emsp;\u9762\u5411\u5bf9\u8c61\u7a0b\u5e8f\u8bbe\u8ba1\u7684\u591a\u6001\u6027\u6307\u4e00\u79cd\u884c\u4e3a\u5bf9\u5e94\u7740\u591a\u79cd\u4e0d\u540c\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002\u591a\u6001\u6027\u5305\u62ec\u9759\u6001\u591a\u6001\u6027\uff08\u7f16\u8bd1\u65f6\u7684\u591a\u6001\u6027\uff09\u548c\u52a8\u6001\u591a\u6001\u6027\uff08\u8fd0\u884c\u65f6\u7684\u591a\u6001\u6027\uff09\u3002<br \/>\n&emsp;&emsp;\u91cd\u8f7d\u6307\u540c\u4e00\u4e2a\u51fd\u6570\u540d\u6709\u591a\u79cd\u4e0d\u540c\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002C++\u7684\u591a\u6001\u6027\u8868\u73b0\u5728\u51fd\u6570\u91cd\u8f7d\u4e0a\u3002<br \/>\n&emsp;&emsp;1. \u652f\u6301\u9759\u6001\u8054\u7f16\u4ee5\u5b9e\u73b0\u9759\u6001\u591a\u6001\u6027\u3002\u9759\u6001\u8054\u7f16\u662f\u6307\u7a0b\u5e8f\u8fd0\u884c\u4e4b\u524d\u5c31\u5df2\u7ecf\u786e\u5b9a\u8be5\u540c\u540d\u63a5\u53e3\u8c03\u7528\u7684\u54ea\u4e00\u4e2a\u7248\u672c\u3002\u6bd4\u5982\u901a\u8fc7\u51fd\u6570\u91cd\u8f7d\u548c\u8fd0\u7b97\u7b26\u91cd\u8f7d\u5b9e\u73b0\u9759\u6001\u8054\u7f16\u3002\u5728\u540c\u4e00\u4e2a\u7c7b\u3001\u65e0\u7ee7\u627f\u5173\u7cfb\u7684\u5e73\u884c\u7c7b\u3001\u4e0d\u5c5e\u4e8e\u4efb\u4f55\u7c7b\u7684\u666e\u901a\u51fd\u6570\u4e2d\uff0c\u540c\u4e00\u4e2a\u51fd\u6570\u540d\u5bf9\u5e94\u4e0d\u540c\u7684\u5b9e\u73b0\u4ee3\u7801\uff0c\u8fd9\u79cd\u591a\u6001\u6027\u79f0\u4e3a\u9759\u6001\u591a\u6001\u6027\u3002<br \/>\n&emsp;&emsp;2. \u652f\u6301\u52a8\u6001\u8054\u7f16\u4ee5\u5b9e\u73b0\u52a8\u6001\u591a\u6001\u6027\u3002\u52a8\u6001\u8054\u7f16\u662f\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u624d\u53ef\u4ee5\u786e\u5b9a\u8be5\u540c\u540d\u63a5\u53e3\u7a76\u7adf\u6765\u81ea\u4e8e\u57fa\u7c7b\u8fd8\u662f\u67d0\u4e00\u4e2a\u6d3e\u751f\u7684\u5b50\u7c7b\u3002\u52a8\u6001\u8054\u7f16\u662f\u5728\u5171\u6709\u7ee7\u627f\u7684\u524d\u63d0\u4e0b\u901a\u8fc7\u865a\u51fd\u6570\u3001\u57fa\u7c7b\u7684\u6307\u9488\u6216\u5f15\u7528\u5b9e\u73b0\u7684\u3002<br \/>\n&emsp;&emsp;\u52a8\u6001\u8054\u7f16\u6548\u7387\u4e0d\u5982\u9759\u6001\u8054\u7f16\uff0c\u4f46\u662f\u5b83\u901a\u8fc7\u9ad8\u5ea6\u62bd\u8c61\u63d0\u9ad8\u7a0b\u5e8f\u7684\u7075\u6d3b\u6027\u548c\u53ef\u6269\u5145\u6027\u3002<\/p>\n<h4>\u5c40\u90e8\u53d8\u91cf<\/h4>\n<hr \/>\n<p>&emsp;&emsp;C++\u8bed\u8a00\u63d0\u4f9b\u4e86\u5c40\u90e8\u53d8\u91cf\u66f4\u52a0\u7075\u6d3b\u7684\u65b9\u5f0f\uff0c\u5c40\u90e8\u53d8\u91cf\u53ef\u4ee5\u968f\u7528\u968f\u5b9a\u4e49\uff0c\u4f5c\u7528\u57df\u4e3a\u8be5\u53d8\u91cf\u5b9a\u4e49\u70b9\u5230\u8be5\u53d8\u91cf\u6240\u5728\u7684\u6700\u5c0f\u7a0b\u5e8f\u5757\u672b\u7684\u8303\u56f4\u3002<br \/>\n&emsp;&emsp;\u5f53\u4e24\u4e2a\u53d8\u91cf\u540c\u540d\uff0c\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\uff0c\u4e00\u4e2a\u5c40\u90e8\u53d8\u91cf\uff0c\u5219\u5728\u5c40\u90e8\u53d8\u91cf\u7684\u4f5c\u7528\u57df\u8303\u56f4\u5185\u8be5\u540c\u540d\u5168\u5c40\u53d8\u91cf\u4e0d\u53ef\u89c1\uff0c\u4f46\u662f\u5728\u53d8\u91cf\u540d\u5b57\u524d\u52a0<strong>\u57df\u89e3\u6790\u7b26<\/strong><code><code>::<\/code><\/code>\u53ef\u4ee5\u8bbf\u95ee\u9690\u85cf\u7684\u540c\u540d\u5168\u5c40\u53d8\u91cf\u3002<strong>\u57df\u89e3\u6790\u9644\u53ea\u80fd\u52a0\u5728\u5168\u5c40\u53d8\u91cf\u524d\uff0c\u4e0d\u53ef\u4ee5\u653e\u5728\u5c40\u90e8\u53d8\u91cf\u7684\u524d\u9762<\/strong>\u3002<\/p>\n<h4>static\u5173\u952e\u5b57<\/h4>\n<hr \/>\n<p>&emsp;&emsp;<code><code>static<\/code><\/code>\u53ef\u4fee\u9970\u51fd\u6570\u548c\u53d8\u91cf\uff0c\u5373\u6709\u9759\u6001\u51fd\u6570\u548c\u9759\u6001\u53d8\u91cf\u3002<br \/>\n&emsp;&emsp;\u53d8\u91cf\u524d\u52a0\u4e0a<code><code>static<\/code><\/code>\u540e\u5c31\u53d8\u6210\u4e86\u9759\u6001\u53d8\u91cf\uff0c\u4f1a\u88ab\u5b58\u653e\u5728\u9759\u6001\u5b58\u50a8\u533a\uff0c\u5728\u6574\u4e2a\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u4e00\u76f4\u5b58\u5728\u3002\u5c40\u90e8\u9759\u6001\u53d8\u91cf\u4f5c\u7528\u57df\u4ecd\u4e3a\u5c40\u90e8\u4f5c\u7528\u57df\uff0c\u5f53\u5b9a\u4e49\u5b83\u7684\u51fd\u6570\u6216\u8005\u8bed\u53e5\u5757\u7ed3\u675f\u7684\u65f6\u5019\uff0c\u4f5c\u7528\u57df\u7ed3\u675f\u3002\u4f46\u662f\u5f53\u5c40\u90e8\u9759\u6001\u53d8\u91cf\u79bb\u5f00\u4f5c\u7528\u57df\u540e\uff0c\u5e76\u6ca1\u6709\u9500\u6bc1\uff0c\u800c\u662f\u4ecd\u7136\u9a7b\u7559\u5728\u5185\u5b58\u5f53\u4e2d\uff0c\u53ea\u4e0d\u8fc7\u6211\u4eec\u4e0d\u80fd\u518d\u5bf9\u5b83\u8fdb\u884c\u8bbf\u95ee\uff0c\u76f4\u5230\u8be5\u51fd\u6570\u518d\u6b21\u88ab\u8c03\u7528\uff0c\u5e76\u4e14\u503c\u4e0d\u53d8\u3002\u5168\u5c40\u9759\u6001\u53d8\u91cf\u5728\u58f0\u660e\u4ed6\u7684\u6587\u4ef6\u4e4b\u5916\u662f\u4e0d\u53ef\u89c1\u7684\uff0c\u51c6\u786e\u5730\u8bf4\u662f\u4ece\u5b9a\u4e49\u4e4b\u5904\u5f00\u59cb\uff0c\u5230\u6587\u4ef6\u7ed3\u5c3e\u3002<br \/>\n&emsp;&emsp;\u5728\u51fd\u6570\u8fd4\u56de\u7c7b\u578b\u524d\u52a0static\uff0c\u51fd\u6570\u5c31\u5b9a\u4e49\u4e3a\u9759\u6001\u51fd\u6570\u3002\u51fd\u6570\u7684\u5b9a\u4e49\u548c\u58f0\u660e\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u90fd\u662fextern\u7684\uff0c\u4f46\u9759\u6001\u51fd\u6570\u53ea\u662f\u5728\u58f0\u660e\u4ed6\u7684\u6587\u4ef6\u5f53\u4e2d\u53ef\u89c1\uff0c\u4e0d\u80fd\u88ab\u5176\u4ed6\u6587\u4ef6\u6240\u7528\u3002\u51fd\u6570\u7684\u5b9e\u73b0\u4f7f\u7528static\u4fee\u9970\uff0c\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u53ea\u53ef\u5728\u672ccpp\u5185\u4f7f\u7528\uff0c\u4e0d\u4f1a\u540c\u5176\u4ed6cpp\u4e2d\u7684\u540c\u540d\u51fd\u6570\u5f15\u8d77\u51b2\u7a81\u3002<br \/>\n&emsp;&emsp;<code><code>static<\/code>`<code>\u5b9a\u4e49\u5728\u4e00\u4e2a\u7c7b\u5185\u90e8\u65f6\uff0c\u8868\u660e\u8be5\u53d8\u91cf\u662f\u7c7b\u7684\u9759\u6001\u6210\u5458\uff0c\u53ef\u4ee5\u5f88\u597d\u7684\u89e3\u51b3\u540c\u4e00\u4e2a\u7c7b\u7684\u4e0d\u540c\u5bf9\u8c61\u4e4b\u95f4\u6570\u636e\u5171\u4eab\u7684\u95ee\u9898\uff0c\u8be5\u6210\u5458\u53ea\u6709\u4e00\u4efd\u62f7\u8d1d\uff0c\u5728\u7c7b\u7684\u4efb\u4f55\u5bf9\u8c61\u88ab\u521b\u5efa\u4e4b\u524d\u5c31\u5df2\u7ecf\u5b58\u5728\uff0c\u56e0\u6b64\u5176\u521d\u59cb\u5316\u5de5\u4f5c\u662f\u5728\u7f16\u8bd1\u65f6\u521b\u9020\u5e76\u521d\u59cb\u5316\u7684\uff0c\u800c\u4e0d\u662f\u6784\u9020\u51fd\u6570\u3002\u7c7b\u7684\u516c\u6709\u9759\u6001\u6210\u5458\u6700\u597d\u7684\u8bbf\u95ee\u65b9\u5f0f\u662f\uff1a<\/code>`<code>\u7c7b\u540d::\u516c\u6709\u9759\u6001\u6210\u5458\u53d8\u91cf\u540d<\/code><\/code>\u3002<br \/>\n&emsp;&emsp;<code><code>static<\/code>`<code>\u52a0\u5728\u7c7b\u7684\u6210\u5458\u51fd\u6570\u4e4b\u524d\u53ef\u5c06\u8be5\u51fd\u6570\u58f0\u660e\u4e3a\u9759\u6001\u6210\u5458\u51fd\u6570\uff0c\u53ef\u4ee5\u5728\u672a\u5b9a\u4e49\u7c7b\u7684\u4efb\u4f55\u5bf9\u8c61\u7684\u60c5\u51b5\u4e0b\uff0c\u8c03\u7528\u9759\u6001\u6210\u5458\u51fd\u6570\u5bf9\u7c7b\u7684\u79c1\u6709\u9759\u6001\u6210\u5458\u8fdb\u884c\u64cd\u4f5c\u3002\u8c03\u7528\u65b9\u5f0f\uff1a<\/code>`<code>\u7c7b\u540d::\u9759\u6001\u6210\u5458\u51fd\u6570<\/code><\/code><\/p>\n<h4>\u5f15\u7528\u548c\u6307\u9488<\/h4>\n<hr \/>\n<p>&emsp;&emsp;\u4eceC++\u7f16\u8bd1\u5668\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u5728\u7f16\u8bd1\u5668\u5185\u90e8\uff0c\u4f7f\u7528\u6307\u9488\u5e38\u91cf(\u5e38\u6307\u9488)\u6765\u5b9e\u73b0\u5f15\u7528\u3002\u56e0\u6b64\u5f15\u7528\u7684\u672c\u8d28\u662f\u6307\u9488\u5e38\u91cf\u3002<br \/>\n&emsp;&emsp;<strong>\u5f15\u7528\u6709\u5185\u5b58\u5417\uff1f\uff1f<\/strong> \u4ece\u7f16\u8bd1\u5668\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u5f15\u7528\u662f\u7528\u6307\u9488\u5b9e\u73b0\u7684\uff0c\u56e0\u6b64\u5f15\u7528\u5360\u6709\u5b9e\u9645\u7684\u5185\u5b58\u7a7a\u95f4\u3002\u4ece\u7528\u6237\u4f7f\u7528\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u5f15\u7528\u662f\u4e00\u4e2a\u53d8\u91cf\u7684\u522b\u540d\uff0c\u76f8\u5f53\u4e8e\u4e00\u4e2a\u53d8\u91cf\u6709\u4e24\u4e2a\u540d\u5b57\uff0c\u5f15\u7528\u4e0d\u5360\u5185\u5b58\u7a7a\u95f4\u3002\u5b9e\u9645\u4e0a\u662f\u5360\u6709\u5185\u5b58\u7684\uff01<\/p>\n<p>&emsp;&emsp;\u6307\u9488\u662f\u4e00\u4e2a\u53d8\u91cf\uff0c\u53d8\u91cf\u91cc\u5b58\u653e\u7684\u662f\u522b\u7684\u53d8\u91cf\u7684\u5730\u5740\uff0c\u56e0\u4e3a\u5b58\u653e\u7684\u662f\u4e00\u4e2a\u5730\u5740\uff0c\u56e0\u6b64\u6307\u9488\u53d8\u91cf\u5360\u7528\u7684\u5185\u5b58\u7a7a\u95f4\u662f\u56fa\u5b9a\u7684\uff1a32\u4f4d\u7f16\u8bd1\u5668\u4e2d\u6307\u9488\u53d8\u91cf\u53604\u5b57\u8282\uff0c64\u4f4d\u53608\u5b57\u8282\u3002<\/p>\n<p>&emsp;&emsp;\u6307\u9488\u5bf9\u53d8\u91cf\u7684\u64cd\u4f5c\u662f\u95f4\u63a5\u64cd\u4f5c\uff0c\u5f15\u7528\u5bf9\u53d8\u91cf\u7684\u64cd\u4f5c\u662f\u76f4\u63a5\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u591a\u6001\u6027 &emsp;&emsp;\u9762\u5411\u5bf9\u8c61\u7a0b\u5e8f\u8bbe\u8ba1\u7684\u591a\u6001\u6027\u6307\u4e00\u79cd\u884c\u4e3a\u5bf9\u5e94\u7740\u591a\u79cd\u4e0d\u540c\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002\u591a\u6001\u6027\u5305 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[66],"tags":[],"_links":{"self":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/1013"}],"collection":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/comments?post=1013"}],"version-history":[{"count":6,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/1013\/revisions"}],"predecessor-version":[{"id":1019,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/1013\/revisions\/1019"}],"wp:attachment":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/media?parent=1013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/categories?post=1013"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/tags?post=1013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}