{"id":930,"date":"2025-12-24T14:18:18","date_gmt":"2025-12-24T06:18:18","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=930"},"modified":"2025-12-24T14:18:18","modified_gmt":"2025-12-24T06:18:18","slug":"c%e6%98%be%e6%80%a7%e5%a5%91%e7%ba%a6%e4%b8%8e%e9%9a%90%e6%80%a7%e8%a7%84%e5%88%99%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/12\/24\/c%e6%98%be%e6%80%a7%e5%a5%91%e7%ba%a6%e4%b8%8e%e9%9a%90%e6%80%a7%e8%a7%84%e5%88%99%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2\/","title":{"rendered":"C++\u663e\u6027\u5951\u7ea6\u4e0e\u9690\u6027\u89c4\u5219:\u7c7b\u578b\u8f6c\u6362\u00a0"},"content":{"rendered":"\n<p>\u5728 C++ \u7684\u4e16\u754c\u91cc\uff0c\u7c7b\u578b\u8f6c\u6362\uff08Type Conversion\uff09\u662f\u4e00\u628a\u53cc\u5203\u5251\u3002\u4e00\u65b9\u9762\uff0c<strong>\u9690\u6027\u89c4\u5219<\/strong>\uff08Implicit Rules\uff09\u8ba9\u4ee3\u7801\u7f16\u5199\u6d41\u7545\uff0c\u51cf\u5c11\u4e86\u5197\u4f59\u7684\u6837\u677f\u4ee3\u7801\uff1b\u53e6\u4e00\u65b9\u9762\uff0c\u8fd9\u4e9b\u770b\u4e0d\u89c1\u7684\u89c4\u5219\u53ef\u80fd\u5bfc\u81f4\u7cbe\u5ea6\u4e22\u5931\u3001\u9519\u8bef\u7684\u91cd\u8f7d\u8c03\u7528\uff0c\u751a\u81f3\u903b\u8f91\u5d29\u6e83\u3002<\/p>\n\n\n\n<p>\u4e3a\u4e86\u9a6f\u670d\u8fd9\u5934\u91ce\u517d\uff0cC++ \u5f15\u5165\u4e86<strong>\u663e\u6027\u5951\u7ea6<\/strong>\uff08Explicit Contracts\uff09\u7684\u6982\u5ff5\u2014\u2014\u901a\u8fc7\u5f3a\u5236\u7684\u8bed\u6cd5\u8981\u6c42\uff0c\u8feb\u4f7f\u7a0b\u5e8f\u5458\u660e\u786e\u8868\u8fbe\u610f\u56fe\u3002\u672c\u6587\u5c06\u6df1\u5165\u5256\u6790\u8fd9\u4e24\u8005\u7684\u535a\u5f08\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001 \u9690\u6027\u89c4\u5219\uff1a\u4fbf\u5229\u80cc\u540e\u7684\u9677\u9631<\/h2>\n\n\n\n<p>\u9690\u5f0f\u8f6c\u6362\u662f C++ \u4ece C \u8bed\u8a00\u7ee7\u627f\u6765\u7684\u7279\u6027\uff0c\u65e8\u5728\u8ba9\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u80fd\u591f\u201c\u81ea\u7136\u201d\u5730\u4ea4\u4e92\u3002\u4f46\u5f53\u7f16\u8bd1\u5668\u8fc7\u4e8e\u201c\u70ed\u5fc3\u201d\u65f6\uff0c\u95ee\u9898\u5c31\u51fa\u73b0\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u6570\u503c\u7c7b\u578b\u7684\u201c\u6084\u6084\u8bdd\u201d (Numeric Conversions)<\/h3>\n\n\n\n<p>\u6700\u5e38\u89c1\u7684\u9690\u60a3\u53d1\u751f\u5728\u57fa\u7840\u6570\u503c\u7c7b\u578b\u4e4b\u95f4\u3002\u7f16\u8bd1\u5668\u4f1a\u81ea\u52a8\u8fdb\u884c<strong>\u79ef\u5206\u63d0\u5347<\/strong>\uff08Integral Promotion\uff09\u6216<strong>\u7b97\u672f\u8f6c\u6362<\/strong>\uff0c\u6709\u65f6\u751a\u81f3\u4f1a\u8fdb\u884c<strong>\u7a84\u5316\u8f6c\u6362<\/strong>\uff08Narrowing Conversion\uff09\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nvoid printPrice(int price) {\n    \/\/ ... \n}\n\ndouble exactPrice = 99.99;\nprintPrice(exactPrice); \/\/ \u9690\u5f0f\u8f6c\u6362\uff1adouble -&gt; int\uff0c\u4e22\u5931\u5c0f\u6570\u90e8\u5206\uff0c\u65e0\u8b66\u544a\uff08\u53d6\u51b3\u4e8e\u7f16\u8bd1\u5668\u7ea7\u522b\uff09\n\n<\/pre><\/div>\n\n\n<p><strong>\u9677\u9631\uff1a<\/strong> \u8fd9\u79cd\u8f6c\u6362\u662f\u9759\u9ed8\u53d1\u751f\u7684\u3002\u5982\u679c\u4e1a\u52a1\u903b\u8f91\u4f9d\u8d56\u7cbe\u5ea6\uff0c\u9690\u5f0f\u622a\u65ad\u5c31\u662f\u81f4\u547d\u7684 Bug\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5355\u53c2\u6570\u6784\u9020\u51fd\u6570\u7684\u201c\u7279\u6d1b\u4f0a\u6728\u9a6c\u201d<\/h3>\n\n\n\n<p>\u8fd9\u662f C++ \u4e2d\u6700\u8457\u540d\u7684\u9690\u5f0f\u8f6c\u6362\u9677\u9631\u3002\u5982\u679c\u4e00\u4e2a\u7c7b\u7684\u6784\u9020\u51fd\u6570\u53ea\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570\uff08\u6216\u8005\u5176\u4ed6\u53c2\u6570\u90fd\u6709\u9ed8\u8ba4\u503c\uff09\uff0c\u7f16\u8bd1\u5668\u4f1a\u5c06\u8fd9\u4e2a\u53c2\u6570\u7c7b\u578b<strong>\u9690\u5f0f\u8f6c\u6362<\/strong>\u4e3a\u8be5\u7c7b\u7684\u5bf9\u8c61\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass Browser {\npublic:\n    \/\/ \u6ca1\u6709 explicit \u5173\u952e\u5b57\n    Browser(int tabCount) { \n        \/\/ \u521d\u59cb\u5316\u6d4f\u89c8\u5668\u7a97\u53e3...\n    }\n};\n\nvoid closeBrowser(const Browser&amp;amp; b) {\n    \/\/ ...\n}\n\nint main() {\n    \/\/ \u672c\u610f\u53ef\u80fd\u662f\u60f3\u4f20\u5165\u4e00\u4e2a\u53e5\u67c4\u6216\u8005\u67d0\u79cd ID\uff0c\n    \/\/ \u4f46\u8fd9\u91cc\u4f20\u5165\u4e86\u6574\u6570 10\u3002\n    \/\/ \u7f16\u8bd1\u5668\u53d1\u73b0 closeBrowser \u9700\u8981 Browser \u5bf9\u8c61\uff0c\n    \/\/ \u4e8e\u662f\u6084\u6084\u8c03\u7528 Browser(10) \u751f\u6210\u4e86\u4e00\u4e2a\u4e34\u65f6\u5bf9\u8c61\uff01\n    closeBrowser(10); \n}\n\n<\/pre><\/div>\n\n\n<p><strong>\u9677\u9631\uff1a<\/strong> <code>closeBrowser(10)<\/code> \u8fd9\u884c\u4ee3\u7801\u6781\u5176\u53cd\u76f4\u89c9\u3002\u6574\u6570 <code>10<\/code> \u5e76\u6ca1\u6709\u201c\u6d4f\u89c8\u5668\u201d\u7684\u8bed\u4e49\uff0c\u4f46\u4ee3\u7801\u5374\u901a\u8fc7\u4e86\u7f16\u8bd1\u3002\u8fd9\u4f1a\u5bfc\u81f4\u51fd\u6570\u91cd\u8f7d\u51b3\u8bae\u51fa\u73b0\u610f\u5916\u7ed3\u679c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u7c7b\u578b\u8f6c\u6362\u8fd0\u7b97\u7b26 (Conversion Operators)<\/h3>\n\n\n\n<p>\u7c7b\u53ef\u4ee5\u5b9a\u4e49 <code>operator T()<\/code> \u5c06\u81ea\u5df1\u8f6c\u6362\u4e3a\u5176\u4ed6\u7c7b\u578b\u3002\u8fd9\u5728\u8bbe\u8ba1\u667a\u80fd\u6307\u9488\uff08\u8f6c\u4e3a bool\uff09\u6216\u4ee3\u7406\u7c7b\u65f6\u5f88\u6709\u7528\uff0c\u4f46\u6ee5\u7528\u4f1a\u5bfc\u81f4\u6b67\u4e49\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass Fraction {\npublic:\n    operator double() const { return (double)num \/ den; }\nprivate:\n    int num, den;\n};\n\nFraction f(1, 2);\ndouble val = f + 0.5; \/\/ \u9690\u5f0f\u8c03\u7528 operator double()\uff0c\u5f88\u65b9\u4fbf\uff0c\u4f46\u4e5f\u53ef\u80fd\u5728\u4e0d\u9700\u8981\u65f6\u88ab\u89e6\u53d1\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001 \u663e\u6027\u5951\u7ea6\uff1a\u628a\u610f\u56fe\u5199\u5728\u8138\u4e0a<\/h2>\n\n\n\n<p>\u73b0\u4ee3 C++ \u5f3a\u8c03\u201cSay what you mean\u201d\uff08\u8a00\u884c\u4e00\u81f4\uff09\u3002\u901a\u8fc7\u663e\u6027\u5951\u7ea6\uff0c\u6211\u4eec\u5265\u593a\u4e86\u7f16\u8bd1\u5668\u7684\u731c\u6d4b\u6743\uff0c\u5c06\u63a7\u5236\u6743\u6536\u56de\u7a0b\u5e8f\u5458\u624b\u4e2d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <code>explicit<\/code> \u5173\u952e\u5b57\uff1a\u5b88\u95e8\u5458<\/h3>\n\n\n\n<p><code>explicit<\/code> \u662f\u9632\u6b62\u610f\u5916\u9690\u5f0f\u8f6c\u6362\u7684\u6700\u5f3a\u5951\u7ea6\u3002\u5b83\u544a\u8bc9\u7f16\u8bd1\u5668\uff1a\u201c\u8fd9\u4e2a\u6784\u9020\u51fd\u6570\u6216\u8f6c\u6362\u51fd\u6570\uff0c\u53ea\u80fd\u5728\u7528\u6237\u660e\u786e\u8981\u6c42\u65f6\u8c03\u7528\u3002\u201d<\/p>\n\n\n\n<p><strong>\u4fee\u590d\u5355\u53c2\u6570\u6784\u9020\u51fd\u6570\uff1a<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass Browser {\npublic:\n    \/\/ \u6dfb\u52a0 explicit\uff1a\u8fd9\u4e0d\u518d\u662f\u4e00\u4e2a\u8f6c\u6362\u6784\u9020\u51fd\u6570\n    explicit Browser(int tabCount) { ... }\n};\n\n\/\/ closeBrowser(10);       \/\/ \u7f16\u8bd1\u9519\u8bef\uff01\u65e0\u6cd5\u5c06 int \u9690\u5f0f\u8f6c\u6362\u4e3a Browser\ncloseBrowser(Browser(10)); \/\/ \u6b63\u786e\uff1a\u663e\u5f0f\u8c03\u7528\u6784\u9020\u51fd\u6570\uff0c\u610f\u56fe\u6e05\u6670\n\n<\/pre><\/div>\n\n\n<p><strong>C++11 \u4e4b\u540e\u7684 <code>explicit<\/code> \u8f6c\u6362\u8fd0\u7b97\u7b26\uff1a<\/strong><\/p>\n\n\n\n<p>\u5728 C++11 \u4e4b\u524d\uff0c\u4e3a\u4e86\u8ba9\u667a\u80fd\u6307\u9488\u80fd\u5728 <code>if (ptr)<\/code> \u4e2d\u4f7f\u7528\uff0c\u6211\u4eec\u9700\u8981\u4e00\u4e9b\u590d\u6742\u7684 Hack\uff08\u5982 Safe Bool Idiom\uff09\u3002C++11 \u5141\u8bb8\u5c06\u8f6c\u6362\u8fd0\u7b97\u7b26\u58f0\u660e\u4e3a <code>explicit<\/code>\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass SafeBool {\npublic:\n    explicit operator bool() const { return true; }\n};\n\nSafeBool s;\nif (s) {}        \/\/ OK\uff1a\u5728\u6761\u4ef6\u5224\u65ad\u8bed\u5883\u4e0b\uff0c\u7f16\u8bd1\u5668\u5141\u8bb8 explicit bool \u8f6c\u6362\uff08\u8fd9\u662f\u7279\u4f8b\uff09\n\/\/ bool b = s;   \/\/ \u9519\u8bef\uff1a\u4e0d\u80fd\u9690\u5f0f\u8d4b\u503c\nbool b = static_cast&amp;lt;bool&gt;(s); \/\/ OK\uff1a\u663e\u5f0f\u8f6c\u6362\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">2. C++ \u98ce\u683c\u8f6c\u578b\uff1a\u4ee5\u6b64\u4e3a\u636e<\/h3>\n\n\n\n<p>C \u98ce\u683c\u7684\u5f3a\u5236\u8f6c\u6362 <code>(type)value<\/code> \u662f\u66b4\u529b\u7684\u3001\u96be\u770b\u7684\uff0c\u4e14\u6781\u96be\u5728\u4ee3\u7801\u4e2d\u641c\u7d22\u3002C++ \u63d0\u4f9b\u4e86\u56db\u79cd\u663e\u6027\u8f6c\u578b\u64cd\u4f5c\u7b26\uff0c\u4ee3\u8868\u4e86\u56db\u79cd\u4e0d\u540c\u7684<strong>\u5951\u7ea6<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>static_cast&lt;T>(e)<\/code><\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u5951\u7ea6<\/strong>\uff1a\u201c\u6211\u662f\u7406\u6027\u7684\u8f6c\u6362\u3002\u201d<\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong>\uff1a\u7528\u4e8e\u826f\u6027\u7684\u3001\u7f16\u8bd1\u5668\u8ba4\u53ef\u7684\u8f6c\u6362\uff08\u5982 int \u8f6c double\uff0c\u57fa\u7c7b\u8f6c\u5b50\u7c7b\u4f46\u4e3b\u8981\u7528\u4e8e\u975e\u591a\u6001\uff0c\u8c03\u7528 explicit \u6784\u9020\u51fd\u6570\uff09\u3002\u5b83\u5728\u7f16\u8bd1\u671f\u8fdb\u884c\u68c0\u67e5\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><code>dynamic_cast&lt;T>(e)<\/code><\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u5951\u7ea6<\/strong>\uff1a\u201c\u6211\u4e0d\u786e\u5b9a\u8fd9\u4e2a\u5bf9\u8c61\u662f\u4e0d\u662f\u8fd9\u4e2a\u7c7b\u578b\uff0c\u8bf7\u5e2e\u6211\u68c0\u67e5\u3002\u201d<\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong>\uff1a\u5b89\u5168\u7684\u5411\u4e0b\u8f6c\u578b\uff08Downcasting\uff09\uff0c\u7528\u4e8e\u591a\u6001\u4f53\u7cfb\u3002\u5982\u679c\u5931\u8d25\uff0c\u8fd4\u56de <code>nullptr<\/code>\uff08\u5bf9\u6307\u9488\uff09\u6216\u629b\u51fa\u5f02\u5e38\uff08\u5bf9\u5f15\u7528\uff09\u3002\u8fd9\u662f\u552f\u4e00\u6709\u8fd0\u884c\u65f6\u5f00\u9500\u7684\u8f6c\u578b\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><code>const_cast&lt;T>(e)<\/code><\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u5951\u7ea6<\/strong>\uff1a\u201c\u6211\u77e5\u9053\u81ea\u5df1\u5728\u5e72\u4ec0\u4e48\uff0c\u6211\u8981\u6682\u65f6\u79fb\u9664 const \u5c5e\u6027\u3002\u201d<\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong>\uff1a\u901a\u5e38\u7528\u4e8e\u5bf9\u63a5\u8001\u65e7\u7684 C \u63a5\u53e3\uff0c\u6216\u8005\u5728\u7279\u5b9a\u573a\u666f\u4e0b\u4fee\u6539 <code>mutable<\/code> \u8bed\u4e49\u3002\u6ee5\u7528\u5373\u672a\u5b9a\u4e49\u884c\u4e3a\uff08Undefined Behavior\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><code>reinterpret_cast&lt;T>(e)<\/code><\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u5951\u7ea6<\/strong>\uff1a\u201c\u628a\u8fd9\u4e9b\u6bd4\u7279\u4f4d\u4ec5\u4ec5\u5f53\u505a\u53e6\u4e00\u79cd\u4e1c\u897f\uff0c\u522b\u95ee\u4e3a\u4ec0\u4e48\u3002\u201d<\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong>\uff1a\u5e95\u5c42\u7cfb\u7edf\u7f16\u7a0b\uff0c\u5982\u5c06\u6307\u9488\u8f6c\u4e3a\u6574\u6570\u3002\u6781\u5176\u5371\u9669\uff0c\u7834\u574f\u4e86\u7c7b\u578b\u7cfb\u7edf\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001 \u73b0\u4ee3 C++ \u7684\u6700\u4f73\u5b9e\u8df5<\/h2>\n\n\n\n<p>\u5728\u73b0\u4ee3 C++ \u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u9075\u5faa\u4ee5\u4e0b\u539f\u5219\u6765\u5e73\u8861\u9690\u6027\u89c4\u5219\u4e0e\u663e\u6027\u5951\u7ea6\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6784\u9020\u51fd\u6570\u9ed8\u8ba4 <code>explicit<\/code><\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u9664\u975e\u4f60\u523b\u610f\u5e0c\u671b\u652f\u6301\u9690\u5f0f\u8f6c\u6362\uff08\u4f8b\u5982\u6a21\u62df\u6574\u6570\u7684 <code>BigInt<\/code> \u7c7b\uff09\uff0c\u5426\u5219\u6240\u6709\u5355\u53c2\u6570\u6784\u9020\u51fd\u6570\u90fd\u5e94\u58f0\u660e\u4e3a <code>explicit<\/code>\u3002<\/li>\n\n\n\n<li>Google C++ Style Guide \u751a\u81f3\u5efa\u8bae\u591a\u53c2\u6570\u6784\u9020\u51fd\u6570\u4e5f\u7528 <code>explicit<\/code>\uff08\u9632\u6b62 C++11 \u5217\u8868\u521d\u59cb\u5316\u5e26\u6765\u7684\u9690\u5f0f\u8f6c\u6362\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u907f\u514d C \u98ce\u683c\u8f6c\u578b<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u6c38\u8fdc\u4f7f\u7528 <code>static_cast<\/code> \u7b49 C++ \u8f6c\u578b\u7b26\u3002\u5b83\u4eec\u5728\u4ee3\u7801\u5ba1\u67e5\uff08Code Review\uff09\u65f6\u975e\u5e38\u663e\u773c\uff0c\u50cf\u7ea2\u8272\u7684\u8b66\u793a\u706f\u4e00\u6837\u63d0\u9192\u9605\u8bfb\u8005\uff1a\u201c\u8fd9\u91cc\u53d1\u751f\u4e86\u7c7b\u578b\u8f6c\u6362\u201d\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u4f7f\u7528\u5217\u8868\u521d\u59cb\u5316\u9632\u6b62\u7a84\u5316\uff08List Initialization\uff09<\/strong>\uff1a<ul><li>C++11 \u7684\u5927\u62ec\u53f7\u521d\u59cb\u5316 <code>{}<\/code> \u5728\u68c0\u6d4b\u5230\u7a84\u5316\u8f6c\u6362\uff08\u5982 double -> int\uff09\u65f6\u4f1a\u76f4\u63a5\u62a5\u9519\uff0c\u800c\u4e0d\u662f\u9690\u5f0f\u622a\u65ad\u3002<\/li><\/ul><code>int x = {3.14}; \/\/ \u7f16\u8bd1\u9519\u8bef\uff01\u663e\u6027\u963b\u6b62\u4e86\u9690\u5f0f\u7684\u6570\u636e\u4e22\u5931 int y = 3.14; \/\/ \u7f16\u8bd1\u901a\u8fc7\uff08\u53ef\u80fd\u6709\u8b66\u544a\uff09\uff0cy \u53d8\u4e3a 3<\/code><\/li>\n\n\n\n<li><strong>\u5229\u7528 <code>std::bit_cast<\/code> (C++20)<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5bf9\u4e8e\u9700\u8981\u91cd\u89e3\u91ca\u5185\u5b58\u4f4d\u7684\u573a\u666f\uff0c\u4f7f\u7528 <code>std::bit_cast<\/code> \u4ee3\u66ff <code>reinterpret_cast<\/code> \u6216 <code>memcpy<\/code>\uff0c\u8fd9\u662f\u7c7b\u578b\u5b89\u5168\u4e14 <code>constexpr<\/code> \u53cb\u597d\u7684\u65b9\u5f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p>C++ \u7684\u7c7b\u578b\u8f6c\u6362\u54f2\u5b66\u53ef\u4ee5\u603b\u7ed3\u4e3a\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u9690\u6027\u89c4\u5219<\/strong>\u662f\u4e3a\u4e86\u65b9\u4fbf\uff0c\u9002\u7528\u4e8e<strong>\u4e0d\u4e22\u5931\u4fe1\u606f\u3001\u8bed\u4e49\u76f8\u901a<\/strong>\u7684\u573a\u666f\uff08\u5982 <code>short<\/code> \u8f6c <code>int<\/code>\uff09\u3002<\/li>\n\n\n\n<li><strong>\u663e\u6027\u5951\u7ea6<\/strong>\u662f\u4e3a\u4e86\u5b89\u5168\uff0c\u9002\u7528\u4e8e<strong>\u53ef\u80fd\u4e22\u5931\u4fe1\u606f\u3001\u6539\u53d8\u8bed\u4e49\u3001\u6216\u4ee3\u4ef7\u6602\u8d35<\/strong>\u7684\u573a\u666f\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4f18\u79c0\u7684 C++ \u7a0b\u5e8f\u5458\u4f1a\u503e\u5411\u4e8e\u4f7f\u7528\u663e\u6027\u5951\u7ea6\u3002\u867d\u7136\u591a\u6572\u4e86\u51e0\u4e2a\u5b57\u7b26\uff0c\u4f46\u4f60\u4e3a\u4ee3\u7801\u4e70\u4e0b\u4e86\u4e00\u4efd\u957f\u671f\u7684\u4fdd\u9669\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>\u8bb0\u4f4f\uff1a\u4ee3\u7801\u88ab\u9605\u8bfb\u7684\u6b21\u6570\u8fdc\u591a\u4e8e\u88ab\u7f16\u5199\u7684\u6b21\u6570\u3002\u663e\u6027\u8f6c\u6362\u8ba9\u9605\u8bfb\u8005\u65e0\u9700\u67e5\u9605\u6587\u6863\u5373\u53ef\u786e\u4fe1\u7c7b\u578b\u53d8\u5316\u7684\u610f\u56fe\u3002<\/strong><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 C++ \u7684\u4e16\u754c\u91cc\uff0c\u7c7b\u578b\u8f6c\u6362\uff08Type Conversion\uff09\u662f\u4e00\u628a\u53cc\u5203\u5251\u3002\u4e00&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/12\/24\/c%e6%98%be%e6%80%a7%e5%a5%91%e7%ba%a6%e4%b8%8e%e9%9a%90%e6%80%a7%e8%a7%84%e5%88%99%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-930","post","type-post","status-publish","format-standard","hentry","category-12"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/930","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=930"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/930\/revisions"}],"predecessor-version":[{"id":931,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/930\/revisions\/931"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}