{"id":580,"date":"2016-07-27T02:41:56","date_gmt":"2016-07-26T18:41:56","guid":{"rendered":"http:\/\/blog.sorayuki.net\/?p=580"},"modified":"2016-10-09T10:36:32","modified_gmt":"2016-10-09T02:36:32","slug":"vc%e9%87%8c4%e3%80%818%e3%80%8112%e5%92%8c16%e5%ad%97%e8%8a%82%e7%9a%84%e6%88%90%e5%91%98%e6%8c%87%e9%92%88","status":"publish","type":"post","link":"https:\/\/blog.sorayuki.net\/?p=580","title":{"rendered":"VC++\u91cc4\u30018\u300112\u548c16\u5b57\u8282\u7684\u6210\u5458\u6307\u9488"},"content":{"rendered":"<p>\u80cc\u666f\u4fe1\u606f\u7b80\u5355\u63d0\u4e00\u4e0b\u2026\u2026\u5927\u6982\u5c31\u662f\u6709\u4e24\u6b21\u88ab\u8fd9\u4e8b\u60c5\u5751\u4e86\uff0c\u6211\u4e00\u76f4\u4ee5\u4e3a\u5b83\u53ea\u662f\u4e00\u4e2a\u666e\u901a\u6307\u9488\u7684\u5927\u5c0f\uff0c32\u4f4d\u4e0b\u662f4\u5b57\u8282\u3002<\/p>\n<p>\u7b2c\u4e00\u6b21\uff0c\u662f\u5728\u524d\u4e00\u5bb6\u516c\u53f8\u7684\u65f6\u5019\uff0c\u9047\u5230\u4e00\u4e2a\u5e94\u7528\u573a\u666f\uff0c\u4e00\u4e2a\u5934\u6587\u4ef6\u9700\u8981\u540c\u65f6\u5728C\u548cC++\u91cc\u7528\uff0c\u91cc\u9762\u5b58\u6709\u4e00\u4e2a\u6210\u5458\u51fd\u6570\u7684\u6307\u9488\uff0c\u548cvoid*\u4e00\u8d77\u653e\u5728union\u91cc\uff0c\u662f\u4e13\u95e8\u7ed9C++\u7528\u7684\uff1bC\u7684\u8bdd\u8fd9\u4e2a\u5730\u65b9\u5c31\u7528\u6761\u4ef6\u7f16\u8bd1\u8bed\u53e5\u6362\u6210\u5355\u4e2avoid*\u3002\u7ed3\u679c\u662f\u6211\u79bb\u5f00\u9879\u76ee\u7ec4\u4e4b\u540e\uff0c\u540e\u9762\u7528\u5230\u8fd9\u6bb5\u4ee3\u7801\u7684\u4eba\u53d1\u73b0\u8fd9\u4e2a\u6210\u5458\u6307\u9488\u6709\u7684\u65f6\u5019\u6bd4void*\u5927\u3002\u4f46\u662f\u90a3\u4e2a\u65f6\u5019\u5df2\u7ecf\u4e0d\u5728\u7ec4\u91cc\u4e86\uff0c\u4e5f\u4e0d\u77e5\u9053\u5177\u4f53\u90a3\u8fb9\u5e94\u7528\u573a\u666f\u662f\u5565\u6837\uff0c\u6700\u540e\u7b80\u5355\u628avoid*\u66ff\u6362\u6210char[32]\u4e86\u4e8b\uff0c\u66f4\u591a\u7684\u4e5f\u6ca1\u5728\u610f\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b21\uff0c\u662f\u5728\u73b0\u5728\u8fd9\u5bb6\u516c\u53f8\u7684\u65f6\u5019\uff0c\u6709\u4e2a\u540c\u4e8b\u5728\u67d0\u4e2a\u5934\u6587\u4ef6\u91cc\u5b9a\u4e49\u7684\u7c7b\u91cc\u9762\u5305\u542b\u4e86\u53e6\u4e00\u4e2a\u7c7b\u7684\u6210\u5458\u51fd\u6570\u6307\u9488\uff0c\u7ed3\u679c\u8fd9\u4e2a\u5934\u6587\u4ef6\u5728\u4e24\u4e2a\u4e0d\u540c\u7684cpp\u6587\u4ef6\u91cc\u5305\u542b\uff0c\u8fd9\u4e2a\u7c7b\u7684\u5927\u5c0f\u662f\u4e0d\u4e00\u6837\u7684\u2026\u2026\u8bbf\u95ee\u6210\u5458\u53d8\u91cf\u7684\u65f6\u5019\u504f\u79fb\u4e5f\u4e0d\u540c\uff0c\u6570\u636e\u5c31\u574f\u4e86\u3002\u4f46\u662fcpp\u91cc\u5934\u6587\u4ef6\u5305\u542b\u7684\u987a\u5e8f\u8c03\u6362\u4e00\u4e0b\u5c31\u80fd\u597d\u2026\u2026\u540c\u4e8b\u8bf4\u662f\u90a3\u4e2a\u6210\u5458\u51fd\u6570\u6307\u9488\u7684\u5927\u5c0f\u4f1a\u4e0d\u540c\uff0c\u4e0d\u8fc7\u90a3\u4f1a\u513f\u5de5\u4f5c\u6709\u70b9\u5fd9\uff0c\u7ed3\u679c\u662f\u6ca1\u653e\u5728\u5fc3\u4e0a\uff0c\u540e\u6765\u5c31\u5fd8\u4e86\u8fd9\u4e8b\u513f\u4e86\u3002<\/p>\n<p>\u6700\u540e\u4e00\u6b21\u662f\u7f51\u53cbAdvance\u5728\u4ee3\u7801\u5f00\u4e86\u6700\u9ad8\u8b66\u544a\u7ea7\u522b\u7684\u65f6\u5019\uff0c\u6709\u4e00\u4e2a\u6210\u5458\u6307\u9488\u88ab\u62a5\u6ca1\u6709\u5bf9\u9f50\u523016\u5b57\u8282\u8fb9\u754c\uff0c\u7136\u540e\u5c31\u6000\u7591\u8fd9\u4e2a\u6307\u9488\u7684\u5927\u5c0f\u3002\u6211\u7a81\u7136\u60f3\u8d77\u4e4b\u524d\u540c\u4e8b\u7684\u4ee3\u7801\u5728\u4e0d\u540c\u6587\u4ef6\u8bbf\u95ee\u53d8\u91cf\u6240\u7528\u7684\u504f\u79fb\u4e0d\u540c\u7684\u4e8b\u60c5\uff0c\u5c31\u6253\u7b97\u7b80\u5355\u8c03\u67e5\u4e00\u4e0b\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u6700\u5f00\u59cb\u662f\u60f3\u8d77\u4e86\u540c\u4e8b\u8bf4\u7684\u6210\u5458\u51fd\u6570\u6307\u9488\u5927\u5c0f\u4f1a\u6bd4\u666e\u901a\u6307\u9488\u5927\u7684\u95ee\u9898\uff0c\u5230\u641c\u7d22\u5f15\u64ce\u4e0a\u641c\u4e86\u4e2a\u5fae\u8f6fmsdn\u793e\u533a\u7684\u5e16\u5b50\uff0c\u6709\u4eba\u63d0\u5230<strong>\u4ec0\u4e48\u6837\u7684\u60c5\u51b5\u6210\u5458\u51fd\u6570\u6307\u9488\u662f\u4ec0\u4e48\u6837\u7684\u5927\u5c0f\uff0c\u5e16\u5b50\u94fe\u63a5\u662f\uff1a<span style=\"text-decoration: underline;\"><a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/vstudio\/en-US\/2793a64f-ec09-495c-b995-4f5b98a26321\/vc-wrong-pointer-size-?forum=vcgeneral\" target=\"_blank\">social.msdn.microsoft.com<\/a><\/span><\/strong>\uff0c\u91cc\u9762\u5927\u6982\u662f\u8bf4\uff0c\u4e00\u4e2a\u6700\u57fa\u672c\u7684\u7c7b\uff0c\u5b83\u7684\u6210\u5458\u51fd\u6570\u6307\u9488\u662f4\u5b57\u8282\uff1b\u5982\u679c\u8fd9\u4e2a\u7c7b\u6709\u591a\u4e2a\u57fa\u7c7b\uff0c\u90a3\u4e48\u5b83\u7684\u6210\u5458\u51fd\u6570\u6307\u9488\u4f1a\u53d8\u62108\u4e2a\u5b57\u8282\uff0c\u5982\u679c\u8fd9\u4e2a\u7c7b\u6709\u865a\u57fa\u7c7b\uff0c\u90a3\u4e48\u5b83\u7684\u6210\u5458\u51fd\u6570\u6307\u9488\u662f12\u5b57\u8282\u3002\u8fd9\u4e2a\u7c7b\u5982\u679c\u90fd\u4e0d\u77e5\u9053\u662f\u5565\u6837\u7684\uff0c\u53ea\u6709\u58f0\u660e\u6ca1\u6709\u5b9a\u4e49\uff0c\u90a3\u4e48\u5c31\u662f16\u5b57\u8282\u3002<\/p>\n<p>\u770b\u5b8c\u4e86\u5e16\u5b50\uff0c\u5c31\u8bf4\u5230\u8fd9\u91cc\u3002\u81f3\u4e8e\u8fd98\u300112\u300116\u5b57\u8282\u91cc\u9762\u662f\u5565\u6837\u7684\uff0c\u6ca1\u6709\u8bf4\u3002\u90a3\u5c31\u81ea\u5df1\u8bd5\u4e00\u4e0b\u5427\u2026\u2026<\/p>\n<h2>4\u5b57\u8282\u7684\u60c5\u51b5<\/h2>\n<p>4\u5b57\u8282\u7684\u60c5\u51b5\u6211\u89c9\u5f97\u6ca1\u5565\u597d\u8bf4\u7684\uff0c\u548c\u666e\u901a\u7684\u51fd\u6570\u6307\u9488\u4e00\u6837\u3002\u4e00\u5b9a\u8981\u8bf4\u6709\u533a\u522b\u7684\u8bdd\uff0c\u5c31\u662f\u591a\u9001\u4e86\u4e00\u4e2a\u53c2\u6570\uff1athis\u6307\u9488\u3002<\/p>\n<h2>8\u5b57\u8282\u7684\u60c5\u51b5<\/h2>\n<p>\u8bf4\u662f\u6709\u591a\u4e2a\u57fa\u7c7b\u7684\u60c5\u51b5\u4f1a\u53d8\u62108\u4e2a\u5b57\u8282\uff0c\u4e8e\u662f\u7528\u4e0b\u9762\u8fd9\u6837\u7684\u4ee3\u7801\u6765\u8bd5\u9a8c\uff0c\u770b\u770b\u7f16\u8bd1\u4ee5\u540e\u4f1a\u6210\u4ec0\u4e48\u6837<\/p>\n<pre>#include &lt;stdio.h&gt;\r\n\r\nstruct A { int a; void af() { printf(\"a=%d\\n\", a); } };\r\nstruct B { int b; void bf() { printf(\"b=%d\\n\", b); } };\r\n\r\nstruct C : public A, public B\r\n{\r\n    int c;\r\n    void cf() { printf(\"c=%d\\n\", c); }\r\n};\r\n\r\nint main()\r\n{\r\n    C x;\r\n    x.a = 1;\r\n    x.b = 2;\r\n    x.c = 3;\r\n    void (C::*p1)() = &amp;C::af;\r\n    void (C::*p2)() = &amp;C::bf;\r\n    void (C::*p3)() = &amp;C::cf;\r\n    printf(\"%d\\n\", sizeof(p1));\r\n    (x.*p1)();\r\n    (x.*p2)();\r\n    (x.*p3)();\r\n}\r\n<\/pre>\n<p>\u770b\u4e86\u4e00\u4e0b\u7f16\u8bd1\u540e\u751f\u6210\u7684\u4ee3\u7801\uff0c\u8fd98\u4e2a\u5b57\u8282\u91cc\u9762\uff0c\u524d4\u4e2a\u5b57\u8282\u662f\u51fd\u6570\u7684\u5730\u5740\uff0c\u5c31\u548c\u524d\u4e00\u79cd\u60c5\u51b5\u2014\u2014\u6ca1\u6709\u591a\u4e2a\u57fa\u7c7b\u2014\u2014\u7684\u65f6\u5019\u662f\u4e00\u6837\u7684\u3002\u81f3\u4e8e\u540e4\u4e2a\u5b57\u8282\uff0c\u662f\u8c03\u7528\u51fd\u6570\u7684\u65f6\u5019\u9001\u5165\u7684this\u6307\u9488\u7684\u504f\u79fb\u3002\u81f3\u4e8e\u4e3a\u4ec0\u4e48\u8981\u504f\u79fb\uff0c\u53ef\u4ee5\u53c2\u8003<span style=\"text-decoration: underline;\"><strong><a href=\"?p=577\" target=\"_blank\">\u8fd9\u7bc7\u535a\u5ba2<\/a><\/strong><\/span>\u3002<\/p>\n<p>\u4e0a\u9762\u7684p1\u3001p2\u3001p3\u53d8\u91cf\u91cc\uff0c\u504f\u79fb\u5206\u522b\u662f0\u30014\u30010\u3002<\/p>\n<p>\u5927\u6982\u5c31\u662f\u8fd9\u79cd\u611f\u89c9\uff1a<\/p>\n<pre>int main()\r\n{\r\n    C x;\r\n    x.a = 1;\r\n    x.b = 2;\r\n    x.c = 3;\r\n    union MemPtr {\r\n        struct {\r\n            void(*funcPtr)();\r\n            int thisOffset;\r\n        };\r\n        void (C::*val)();\r\n    } p;\r\n    p.val = &amp;C::bf;\r\n    __asm {\r\n        lea eax, p\r\n        mov edx, MemPtr::thisOffset\r\n        mov ecx, dword ptr [eax+edx]\r\n        lea eax, x\r\n        add ecx, eax\r\n        lea eax, p\r\n        mov edx, MemPtr::funcPtr\r\n        mov eax, dword ptr [eax+edx]\r\n        call eax\r\n    }\r\n}<\/pre>\n<p>\u7b80\u5355\u89e3\u91ca\u4e00\u4e0b\uff0c\u5c31\u662f\u8c03\u7528\u7684\u65f6\u5019\uff0cthis=&amp;x + p.thisOffset\u3002<\/p>\n<p>\u4e0a\u9762\u7a0b\u5e8f\u8fd0\u884c\u7ed3\u679c\u662fb=2\u3002<\/p>\n<h2>12\u5b57\u8282\u7684\u60c5\u51b5<\/h2>\n<p>\u591a\u7684\u4e0d\u8bf4\uff0c\u76f4\u63a5\u4e0a\u6d4b\u8bd5\u4ee3\u7801<\/p>\n<pre>#include &lt;stdio.h&gt;\r\n\r\nstruct D {\r\n    virtual ~D(){}\r\n    int d;\r\n    void df() { printf(\"d=%d\\n\", d); }\r\n};\r\n\r\nstruct A : virtual public D { int a; void af() { printf(\"a=%d\\n\", a); } };\r\nstruct B : virtual public D { int b; void bf() { printf(\"b=%d\\n\", b); } };\r\n\r\nstruct C : public A, public B\r\n{\r\n    int c;\r\n    void cf() { printf(\"c=%d\\n\", c); }\r\n};\r\n\r\nint main()\r\n{\r\n    C x;\r\n    x.a = 1;\r\n    x.b = 2;\r\n    x.c = 3;\r\n    x.d = 4;\r\n\r\n    void (C::*p)() = &amp;C::df;\r\n    printf(\"%d\\n\", sizeof(p));\r\n    (x.*p)();\r\n}<\/pre>\n<p>\u56e0\u4e3a\u5bf9\u865a\u57fa\u7c7b\u60c5\u51b5\u4e0b\u5bf9\u8c61\u5728\u5185\u5b58\u4e2d\u7684\u8868\u793a\u4e0d\u719f\uff0c\u4f46\u662f\u73b0\u5728\u53c8\u592a\u8fdf\u4e86\uff0c\u8fd9\u4e2a\u5c31\u4ee5\u540e\u518d\u7814\u7a76\u2026\u2026\u5148\u770b\u5b83\u8fd9\u4e2a\u6307\u9488\u5728\u5e72\u561b\u3002<\/p>\n<p>\u8fd9\u4e2a12\u5b57\u8282\u7684\u6307\u9488\uff0c\u2460\u6700\u524d\u97624\u5b57\u8282\u653e\u7684\u662f\u51fd\u6570\u7684\u5730\u5740\uff0c\u548c4\u5b57\u8282\u30018\u5b57\u8282\u7684\u60c5\u51b5\u4e00\u6837\uff1b\u2461\u4e2d\u95f44\u5b57\u8282\u585e\u7684\u4e1c\u897f\u662f\u201c\u865a\u8868\u4e2d\u7684\u504f\u79fb\u201d\uff1a\u6709\u865a\u57fa\u7c7b\u7684\u60c5\u51b5\uff0c\u7f16\u8bd1\u5668\u4f1a\u5728\u865a\u8868\u91cc\u9762\u585e\u4e0a\u8fd9\u4e2a\u865a\u57fa\u7c7b\u7684\u5bf9\u8c61\u5728\u5f53\u524d\u5bf9\u8c61\u4e2d\u7684\u504f\u79fb\u3002\u56e0\u4e3a\u53ef\u80fd\u4f1a\u6709\u591a\u4e2a\u8fd9\u79cd\u865a\u57fa\u7c7b\uff0c\u5728\u8c03\u7528\u6210\u5458\u51fd\u6570\u6307\u9488\u7684\u65f6\u5019\uff0cthis\u6307\u9488\u5e94\u8be5\u6307\u5411\u8c01\uff08\u6362\u53e5\u8bdd\u8bf4\u4e5f\u5c31\u662fthis\u6307\u9488\u8981\u5982\u4f55\u8c03\u6574\uff09\uff0c\u662f\u9760\u4e2d\u95f4\u8fd94\u5b57\u8282\u51b3\u5b9a\u7684\u3002\u5728\u4e0a\u9762\u4f8b\u5b50\u4e2d\uff0c\u5c31\u662f\u4eceC*\u8f6c\u6362\u5230D*\u7684\u8fc7\u7a0b\uff1b\u2462\u6700\u540e4\u5b57\u8282\u5b58\u653e\u7684\u662fthis\u6307\u9488\u5728\u8fd9\u6837\u8c03\u6574\u4e4b\u540e\uff0c\u8fd8\u8981\u5982\u4f55\u8c03\u6574\uff1a\u5728\u4e0a\u9762\u4f8b\u5b50\u4e2d\u56e0\u4e3aD\u5df2\u7ecf\u662f\u6700\u57fa\u672c\u7684\u7c7b\u4e86\uff0c\u6240\u4ee5\u8fd9\u91cc\u662f0\uff1b\u4f46\u5982\u679c\u6307\u5411\u7684\u662fD\u7684\u591a\u4e2a\u57fa\u7c7b\u4e2d\u5176\u4e2d\u4e00\u4e2a\u7684\u6210\u5458\u51fd\u6570\u7684\u6307\u9488\uff0c\u90a3\u4e48\u8fd9\u91cc\u5c31\u4e0d\u662f0\u3002<\/p>\n<p>\u7b80\u5355\u8bf4\u5c31\u662f\u8fd912\u5b57\u8282\uff0c\u67098\u5b57\u8282\u662f\u8bf4\u660ethis\u6307\u9488\u8981\u600e\u4e48\u8f6c\u6362\u3002<\/p>\n<p>\u628a\u4e0a\u9762\u7684\u4ee3\u7801\u518d\u5f04\u590d\u6742\u4e00\u70b9\uff0c\u6bd4\u5982<\/p>\n<pre>#include &lt;stdio.h&gt;\r\nstruct X { int x; void xf() { printf(\"x=%d\\n\", x); } };\r\nstruct Y { int y; void yf() { printf(\"y=%d\\n\", y); } };\r\n\r\nstruct D : public X, public Y { virtual ~D(){} int d; void df() { printf(\"d=%d\\n\", d); } };\r\n\r\nstruct A : virtual public D { int a; void af() { printf(\"a=%d\\n\", a); } };\r\nstruct B : virtual public D { int b; void bf() { printf(\"b=%d\\n\", b); } };\r\n\r\nstruct C : public A, public B\r\n{\r\n    int c;\r\n    void cf() { printf(\"c=%d\\n\", c); }\r\n};\r\n\r\nint main()\r\n{\r\n    C x;\r\n    x.x = -1;\r\n    x.y = -2;\r\n    x.a = 1;\r\n    x.b = 2;\r\n    x.c = 3;\r\n    x.d = 4;\r\n\r\n    void (C::*p)() = &amp;C::xf;\r\n    (x.*p)();\r\n}\r\n<\/pre>\n<p>\u89c2\u5bdf\u751f\u6210\u7684\u4ee3\u7801\u5c31\u53ef\u4ee5\u53d1\u73b0\uff0c\u8fd9\u4e2ap\u7684\u540e8\u4e2a\u5b57\u8282\u7684\u6570\u636e\u662f4\u548c4\u3002\u524d\u4e00\u4e2a\u6570\u636e\u4ee3\u8868\u53d6\u865a\u8868\u4e2d\u7b2c4\u5b57\u8282\u7684\u504f\u79fb\u5bf9this\u8fdb\u884c\u7b2c\u4e00\u6b21\u8c03\u6574\uff0c\u540e\u4e00\u4e2a\u6570\u636e\u4ee3\u8868\u5728\u8fd9\u4e4b\u540e\u7ee7\u7eed\u50cf8\u4e2a\u5b57\u8282\u90a3\u79cd\u60c5\u51b5\u5bf9this\u8fdb\u884c\u7b2c\u4e8c\u6b21\u8c03\u6574\u3002<\/p>\n<h2>16\u5b57\u8282\u7684\u60c5\u51b5<\/h2>\n<p>\u8bf4\u5b9e\u8bdd\uff0c16\u5b57\u8282\u7684\u60c5\u51b5\u6211\u81ea\u5df1\u5df2\u7ecf\u770b\u4e0d\u51fa\u540d\u5802\u6765\u4e86\u3002\u4ee3\u7801\u6700\u7ec8\u4fee\u6539\u5230<\/p>\n<pre>#include &lt;stdio.h&gt;\r\n\r\nstruct C;\r\nvoid (C::*p)();\r\n\r\nstruct X { int x; void xf() { printf(\"x=%d\\n\", x); } };\r\nstruct Y { int y; void yf() { printf(\"y=%d\\n\", y); } };\r\n\r\nstruct D : public X, public Y { virtual ~D(){} int d; void df() { printf(\"d=%d\\n\", d); } };\r\n\r\nstruct A : virtual public D { int a; void af() { printf(\"a=%d\\n\", a); } };\r\nstruct B : virtual public D { int b; void bf() { printf(\"b=%d\\n\", b); } };\r\n\r\nstruct C : public A, public B\r\n{\r\n    int c;\r\n    void cf() { printf(\"c=%d\\n\", c); }\r\n};\r\n\r\nint main()\r\n{\r\n    printf(\"%d\\n\", sizeof(p));\r\n    C x;\r\n    x.x = -1;\r\n    x.y = -2;\r\n    x.a = 1;\r\n    x.b = 2;\r\n    x.c = 3;\r\n    x.d = 4;\r\n\r\n    p = &amp;C::xf;\r\n    (x.*p)();\r\n}\r\n<\/pre>\n<p>\u8fd9\u79cd\u7a0b\u5ea6\uff0c\u6bd4\u8d77\u524d\u9762\u53ef\u4ee5\u770b\u51fa\u5c31\u662f\u591a\u4e86\u4e2a\u524d\u7f6e\u58f0\u660e\u800c\u5df2\u3002\u548c\u524d\u976212\u5b57\u8282\u7684\u65f6\u5019\u76f8\u6bd4\uff0c\u751f\u6210\u7684\u4ee3\u7801\u5728\u524d\u976212\u5b57\u8282\u7684\u57fa\u7840\u4e0a\uff0c\u5f80\u4e2d\u95f44\u5b57\u8282\u548c\u6700\u540e4\u5b57\u8282\u7684\u6570\u636e\u4e4b\u95f4\u63d2\u5165\u4e86\u4e00\u4e2a4\u5b57\u8282\u7684\u6574\u65700\u3002\u4f46\u662f\u5728\u4e0b\u9762\u7684\u4ee3\u7801\u91cc\u5374\u6ca1\u6709\u7528\u5230\u8fd9\u4e2a0\u3002<\/p>\n<p>\u8c03\u7528\u7684\u5730\u65b9\u4ee3\u7801\u53d8\u5f97\u590d\u6742\u4e86\uff0c\u56e0\u4e3a\u524d\u7f6e\u58f0\u660e\u7684\u7f18\u6545\uff0c\u8fd9\u4e2a\u6307\u9488\u4e0d\u77e5\u9053\u6700\u540e\u4f1a\u88ab\u7528\u5230\u4ec0\u4e48\u6837\u7684\u5730\u65b9\u4e0a\u9762\u3002\u4e8e\u662f\u8c03\u7528\u8fd9\u4e2a\u6307\u9488\u7684\u65f6\u5019\uff0c\u4ee3\u7801\u4f1a\u5148\u5224\u65ad\u8fd9\u4e2a\u6307\u9488\u7684\u6700\u540e4\u4e2a\u5b57\u8282\u662f\u4e0d\u662f0\uff0c\u5982\u679c\u662f\uff0c\u5c31\u76f4\u63a5\u62ff\u7b2c\u4e8c\u4e2a4\u5b57\u8282\u6574\u6570\u6765\u5bf9this\u505a\u504f\u79fb\u7136\u540e\u8c03\u7528\u51fd\u6570\uff1b\u5982\u679c\u4e0d\u662f\uff0c\u5c31\u53d6\u865a\u8868\u4e2d\u8fd9\u4e2a\u4f4d\u7f6e\u4e0a\u7684\u6570\u636e\u53bb\u5bf9this\u505a\u504f\u79fb\uff0c\u7136\u540e\u518d\u53d6\u6210\u5458\u51fd\u6570\u6307\u9488\u91cc\u7b2c\u4e8c\u4e2a4\u5b57\u8282\u6570\u636e\u76f4\u63a5\u52a0\u5230this\u4e0a\u505a\u7b2c\u4e8c\u6b21\u504f\u79fb\uff0c\u518d\u7136\u540e\u8c03\u7528\u51fd\u6570\u3002<\/p>\n<p>\u81f3\u4e8e\u6307\u9488\u4e2d\u7b2c\u4e09\u4e2a4\u5b57\u8282\u6574\u6570\u662f\u5e72\u561b\u7528\u7684\uff0c\u786e\u5b9e\u8fd8\u6ca1\u8c03\u67e5\u51fa\u6765\u3002\u51cc\u66682:40\u65f6\u95f4\u592a\u665a\u4e86\uff0c\u660e\u5929\u8fd8\u8981\u4e0a\u73ed\uff0c\u5c31\u4e0d\u4f5c\u5927\u6b7b\u4e86\uff0c\u4e0b\u6b21\u6709\u65f6\u95f4\u6709\u7cbe\u529b\u518d\u8c03\u67e5\u3002<\/p>\n<p><strong>\u8865\u5145\uff1a<\/strong>\u751f\u6210\u7684\u4ee3\u7801\u91cc\u6ca1\u6709\u7528\u5230\u8fd9\u4e2a0\u662f\u56e0\u4e3a\u5728\u8c03\u7528\u7684\u5730\u65b9\uff0c\u5df2\u7ecf\u77e5\u9053\u7c7b\u7684\u7ed3\u6784\u662f\u4ec0\u4e48\u6837\u7684\u3001\u4e0d\u9700\u8981\u8fd9\u4e2a0\u4e86\u3002\u4e0d\u7136\u5b834\u4e2a4\u5b57\u8282\u6570\u636e\u5206\u522b\u662f\u51fd\u6570\u5730\u5740\u3001\u7b2c\u4e00\u6b21this\u6307\u9488\u504f\u79fb\u8c03\u6574\u3001\u865a\u57fa\u7c7b\u3001\u865a\u57fa\u7c7b\u4e4b\u540e\u7684\u518d\u4e00\u6b21this\u6307\u9488\u504f\u79fb\u8c03\u6574\u3002<\/p>\n<h2>\u540c\u4e00\u4e2a\u5934\u6587\u4ef6\u91cc\u7684\u7c7b\u5728\u4e0d\u540cCPP\u5305\u542b\u5927\u5c0f\u4f1a\u4e0d\u540c\u7684\u539f\u56e0<\/h2>\n<p>\u8bf4\u7a7f\u4e86\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u4e00\u4e2a\u7c7b\u53ea\u6709\u524d\u7f6e\u58f0\u660e\u7684\u65f6\u5019\uff0c\u5b83\u7684\u6210\u5458\u51fd\u6570\u6307\u9488\u662f16\u5b57\u8282\uff1b\u4f46\u662f\u5982\u679c\u67d0\u4e2aCPP\u5df2\u7ecf\u5305\u542b\u8fc7\u8fd9\u4e2a\u201c\u53ea\u6709\u524d\u7f6e\u58f0\u660e\u7684\u7c7b\u201d\u7684\u5b8c\u6574\u5b9a\u4e49\u7684\u65f6\u5019\uff0c\u5b83\u7684\u6210\u5458\u51fd\u6570\u6307\u9488\u5c31\u662f4\u6216\u80058\u6216\u800512\u5b57\u8282\u3002\u6709\u7684CPP\u5305\u542b\u4e86\u8fd9\u4e2a\u6709\u7c7b\u7684\u5b8c\u6574\u5b9a\u4e49\u7684\u5934\u6587\u4ef6\uff0c\u6709\u7684CPP\u5374\u6ca1\u6709\u3001\u53ea\u80fd\u770b\u5230\u524d\u7f6e\u58f0\u660e\u3002\u51b5\u4e14\u5305\u542b\u4e86\u5b8c\u6574\u5b9a\u4e49\u5934\u6587\u4ef6\u7684CPP\uff0c\u53ef\u80fd\u662f\u5728\u58f0\u660e\u8fd9\u6837\u7684\u6307\u9488\u4e4b\u524d\u5305\u542b\uff0c\u4e5f\u53ef\u80fd\u662f\u5728\u58f0\u660e\u8fd9\u6837\u7684\u6307\u9488\u4e4b\u540e\u5305\u542b\uff0c\u6240\u4ee5\u8c03\u6362\u4e00\u4e0b\u5934\u6587\u4ef6\u987a\u5e8f\u7ed3\u679c\u4e5f\u4f1a\u4e0d\u4e00\u6837\u3002<\/p>\n<p>\u90a3\u4e48\u8fd9\u6837\u7684\u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f\u7f51\u53cbfeatherwit\u7ed9\u51fa\u4e86\u4e00\u4e2a\u9760\u8c31\u7684\u65b9\u6848\uff1a<span style=\"text-decoration: underline;\"><strong><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/yad46a6z.aspx\" target=\"_blank\">\u4f7f\u7528\u7f16\u8bd1\u53c2\u6570\/vmg<\/a><\/strong><\/span>\uff08\u5176\u5b9e\u4e4b\u524d\u90a3\u4e2aMSDN\u793e\u533a\u7684\u5e16\u5b50\u91cc\uff0c\u90a3\u4eba\u4f3c\u4e4e\u4e5f\u63d0\u5230\u8fc7\u4e86\uff0c\u8bf4\u52a0\u4e86\u8fd9\u4e2a\u53c2\u6570\u5c31\u4e00\u5b9a\u662f12\u5b57\u8282\uff09\u3002\u4e0d\u8fc7\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u6211\u8bd5\u51fa\u6765\u662f\u52a0\u4e86\u8fd9\u4e2a\u53c2\u6570\u4ee5\u540e\u5c31\u90fd\u662f16\u5b57\u8282\uff0c\u603b\u4e4b\u662f\u7edf\u4e00\u5927\u5c0f\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><del>\u679c\u7136\u8fd8\u662f\u5728\u610f16\u5b57\u8282\u7684\u60c5\u51b5\u4e0b\u7b2c3\u4e2a4\u5b57\u8282\u6574\u6570\u5b58\u7684\u5230\u5e95\u662f\u4ec0\u4e48\u3002<br \/>\n<\/del>\u2190\u5df2\u7ecf\u8865\u5145\u4e86<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f\u4fe1\u606f\u7b80\u5355\u63d0\u4e00\u4e0b\u2026\u2026\u5927\u6982\u5c31\u662f\u6709\u4e24\u6b21\u88ab\u8fd9\u4e8b\u60c5\u5751\u4e86\uff0c\u6211\u4e00\u76f4\u4ee5\u4e3a\u5b83\u53ea\u662f\u4e00\u4e2a\u666e\u901a\u6307\u9488\u7684\u5927\u5c0f\uff0c32\u4f4d\u4e0b\u662f4\u5b57\u8282\u3002 \u7b2c\u4e00 &hellip; <a href=\"https:\/\/blog.sorayuki.net\/?p=580\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">VC++\u91cc4\u30018\u300112\u548c16\u5b57\u8282\u7684\u6210\u5458\u6307\u9488<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-580","post","type-post","status-publish","format-standard","hentry","category-vc"],"_links":{"self":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/posts\/580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=580"}],"version-history":[{"count":0,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/posts\/580\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}