{"id":1284,"date":"2017-04-10T17:09:08","date_gmt":"2017-04-10T09:09:08","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=1284"},"modified":"2017-04-10T17:09:08","modified_gmt":"2017-04-10T09:09:08","slug":"c-%e5%a4%9a%e6%80%81","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=1284","title":{"rendered":"c++ \u591a\u6001"},"content":{"rendered":"<p>\n\t\u7f51\u4e0a\u5173\u4e8eC++\u7684\u6587\u7ae0\u6ca1\u6709 java \u7684\u591a\uff0c\u8fd9\u548c java \u5927\u591a\u6570\u6846\u67b6\u90fd\u5f00\u6e90\u7684\u5173\u7cfb\u5bc6\u5207\u76f8\u5173\u3002\u4eca\u5929\u4e3a\u5927\u5bb6\u5206\u4eab\u4e00\u7bc7C++ \u9762\u5411\u5bf9\u8c61 \u591a\u6001\u7684\u6587\u7ae0\uff01\n<\/p>\n<h2>\n\t\u4ec0\u4e48\u662f\u591a\u6001<br \/>\n<\/h2>\n<p>\n\t\u5b66\u8fc7java\u7684\u4eba\uff0c\u6211\u60f3\u8fd9\u5bf9\u4ed6\u4e00\u5b9a\u4e0d\u964c\u751f\u3002\n<\/p>\n<p>\n\t<a href=\"http:\/\/baike.baidu.com\/item\/\u591a\u6001\" name=\"\u591a\u6001\" target=\"_blank\" title=\"\u591a\u6001\">\u591a\u6001<\/a>\uff1a\u5b57\u9762\u610f\u601d\u5c31\u662f\u591a\u79cd\u5f62\u6001\u3002\u5728\u9762\u5411\u5bf9\u8c61\u8bed\u8a00\u4e2d\uff0c\u63a5\u53e3\u7684\u591a\u79cd\u4e0d\u540c\u5b9e\u73b0\u65b9\u5f0f\u5373\u4e3a\u591a\u6001\uff01&nbsp;<br \/>\n\t\u5728c++\u4e2d\u4e5f\u662f\u5982\u6b64\uff0c\u540c\u4e00\u64cd\u4f5c\u4f5c\u7528\u4e8e\u4e0d\u540c\u7684\u5bf9\u8c61\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u89e3\u91ca\uff0c\u6709\u4e0d\u540c\u7684\u7ed3\u679c\u3002\u5728\u8fd0\u884c\u65f6\u53ef\u4ee5\u901a\u8fc7\u6307\u5411\u57fa\u7c7b\u7684\u6307\u9488\uff0c\u6765\u8c03\u7528\u5b9e\u73b0<a href=\"http:\/\/baike.baidu.com\/item\/\u6d3e\u751f\u7c7b\" name=\"\u6d3e\u751f\u7c7b\" target=\"_blank\" title=\"\u6d3e\u751f\u7c7b\">\u6d3e\u751f\u7c7b<\/a>\u4e2d\u7684\u65b9\u6cd5\u3002&nbsp;\n<\/p>\n<p>\n\t\u5728c++\u4e2d\u5b9e\u73b0\u591a\u6001\u7684\u65b9\u6cd5\uff1a<a href=\"http:\/\/baike.baidu.com\/item\/\u865a\u51fd\u6570\" name=\"\u865a\u51fd\u6570\" target=\"_blank\" title=\"\u865a\u51fd\u6570\">\u865a\u51fd\u6570<\/a>\uff0c<a href=\"http:\/\/baike.baidu.com\/item\/\u62bd\u8c61\u7c7b\" name=\"\u62bd\u8c61\u7c7b\" target=\"_blank\" title=\"\u62bd\u8c61\u7c7b\">\u62bd\u8c61\u7c7b<\/a>\uff0c\u8986\u76d6\uff0c\u6a21\u677f\uff08\u6ce8\u610f\uff1a\u91cd\u8f7d\u548c\u591a\u6001\u65e0\u5173\uff01\uff09\n<\/p>\n<h2>\n\t\u5bf9\u8c61\u7c7b\u578b<br \/>\n<\/h2>\n<p>\n\t<img decoding=\"async\" alt=\"C++ \u5bf9\u8c61\u7c7b\u578b\" src=\"http:\/\/img.blog.csdn.net\/20170409223143952\" style=\"width: 812px;height: 264px\" \/>\n<\/p>\n<p>\n\t\u770b\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"C++ \u9759\u6001\u7c7b\u578b\" src=\"http:\/\/img.blog.csdn.net\/20170409224953008\" style=\"width: 575px;height: 390px\" \/>\n<\/p>\n<p>\n\t\u9759\u6001\u5206\u7c7b\uff1a\u9759\u6001\u591a\u6001\uff08\u51fd\u6570\u91cd\u8f7d\uff0c\u6cdb\u578b\u7f16\u7a0b\uff09\uff1b\u52a8\u6001\u591a\u6001\uff08\u865a\u51fd\u6570\uff09 \u3002\n<\/p>\n<h2>\n\t\u9759\u6001\u591a\u6001<br \/>\n<\/h2>\n<pre class=\"brush:cpp;\">\r\nint add(int left, int right)\r\n{\r\n    return left + right;\r\n}\r\nfloat add(float left, float right)\r\n{\r\n    return left + right;\r\n}\r\n\r\nint main()\r\n{\r\n    cout &lt;&lt; add(1, 2) &lt;&lt; endl;\r\n    cout &lt;&lt; add(1.1f, 2.2f) &lt;&lt; endl;\r\n    system(&quot;pause&quot;);\r\n    return 0;\r\n}<\/pre>\n<h2>\n\t\u52a8\u6001\u591a\u6001<br \/>\n<\/h2>\n<p>\n\t\u770b\u4e0b\u4e48\u7684\u4f8b\u5b50\uff1a\n<\/p>\n<pre class=\"brush:cpp;\">\r\nclass CWashRoom\r\n{\r\npublic:\r\n    void GotoManWashRoom()\r\n    {\r\n        cout &lt;&lt; &quot;Man----&gt;please left&quot; &lt;&lt; endl;\r\n    }\r\n    void GotoWomanWashRoom()\r\n    {\r\n        cout &lt;&lt; &quot;Woman---&gt;please right&quot; &lt;&lt; endl;\r\n    }\r\n};\r\nclass Person\r\n{\r\npublic:\r\n    virtual void GotoWashRoom(CWashRoom&amp;_washroom) = 0;\r\n};\r\n\r\nclass man :public Person\r\n{\r\npublic:\r\n    virtual void GotoWashRoom(CWashRoom&amp;_washroom)\r\n    {\r\n        _washroom.GotoManWashRoom();\r\n    }\r\n};\r\nclass woman :public Person\r\n{\r\npublic:\r\n    virtual void GotoWashRoom(CWashRoom&amp;_washroom)\r\n    {\r\n        _washroom.GotoWomanWashRoom();\r\n    }\r\n};\r\n\r\nvoid test()\r\n{\r\n    CWashRoom washroom;\/\/\u521b\u5efaCWashRoom\u7c7b\u7684\u5bf9\u8c61washroom\r\n    int i = 0;\r\n    for (i = 1; i &lt;= 10; ++i)\r\n    {\r\n        Person* pperson;\/\/\u521b\u5efaperson\u7c7b\u6307\u9488\uff0c\u5b9e\u73b0\u57fa\u7c7b\u65b9\u6cd5\u7684\u8c03\u7528\r\n        int iper = rand() % i;\r\n        if (iper &amp; 0x01)\r\n        {\r\n            pperson = new man;\r\n        }\r\n        else\r\n        {\r\n            pperson = new woman;\r\n        }\r\n        pperson-&gt;GotoWashRoom(washroom);\r\n        delete pperson;\r\n        pperson = NULL;\r\n        Sleep(1000);\r\n    }\r\n}\r\nint main()\r\n{\r\n    test();\r\n    system(&quot;pause&quot;);\r\n    return 0;\r\n}<\/pre>\n<p>\n\t\u8fd9\u91cc\u9762\u6d89\u53ca\u5230\u91cd\u5199\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"C++ \u9762\u5411\u5bf9\u8c61 \u91cd\u5199\" src=\"http:\/\/img.blog.csdn.net\/20170410140826053\" style=\"width: 504px;height: 350px\" \/>\n<\/p>\n<p>\n\tvirtual:\u5173\u952e\u5b57\u4fee\u9970\u7c7b\u6210\u5458\u51fd\u6570\u65f6\uff0c\u6307\u660e\u8be5\u51fd\u6570\u4e3a\u865a\u51fd\u6570\uff0c\u6d3e\u751f\u7c7b\u9700\u8981\u91cd\u65b0\u5b9e\u73b0\uff0c\u7f16\u8bd1\u5668\u5c06\u4f1a\u5b9e\u73b0\u52a8\u6001\u7ed1\u5b9a\u3002\n<\/p>\n<p>\n\t\u52a8\u6001\u7ed1\u5b9a\u7684\u6761\u4ef6\uff1a\n<\/p>\n<ol>\n<li>\n\t\t\u5fc5\u987b\u662f\u865a\u51fd\u6570&nbsp;\n\t<\/li>\n<li>\n\t\t\u901a\u8fc7\u57fa\u7c7b\u7c7b\u578b\u7684\u5f15\u7528\u6216\u8005\u6307\u9488\u8c03\u7528\u865a\u51fd\u6570\n\t<\/li>\n<\/ol>\n<h2>\n\t\u7ee7\u627f\u4f53\u7cfb\u4e2d\u540c\u540d\u51fd\u6570\u7684\u5173\u7cfb<br \/>\n<\/h2>\n<p>\n\t<img decoding=\"async\" alt=\"C++ \u9762\u5411\u5bf9\u8c61 \u7ee7\u627f\" src=\"http:\/\/img.blog.csdn.net\/20170410134325880\" style=\"width: 1163px;height: 403px\" \/>\n<\/p>\n<h2>\n\t\u603b\u7ed3<br \/>\n<\/h2>\n<ol>\n<li>\n\t\t\u5728\u7ee7\u627f\u7684\u7ed3\u6784\u4e0b\uff0c\u57fa\u7c7b\u5fc5\u987b\u8981\u6709\u6709\u865a\u51fd\u6570\uff0c\u6d3e\u751f\u7c7b\u4e2d\u5fc5\u987b\u8981\u5bf9\u57fa\u7c7b\u7684\u865a\u51fd\u6570\u8fdb\u884c\u91cd\u5199\uff0c\u901a\u8fc7\u57fa\u7c7b\u7684\u6307\u9488\u6216\u8005\u5f15\u7528\u8bbf\u95ee\u3002&nbsp;\n\t<\/li>\n<li>\n\t\t\u6784\u9020\u51fd\u6570\u4e0d\u80fd\u4f5c\u4e3a\u865a\u51fd\u6570\u3002\uff081\uff0c\u56e0\u4e3a\u521b\u5efa\u5bf9\u8c61\u65f6\u6211\u4eec\u603b\u8981\u660e\u786e\u6307\u5b9a\u5bf9\u8c61\u7684\u7c7b\u578b\uff0c\u800c\u865a\u51fd\u6570\u5b9e\u5728\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u786e\u5b9a\u5b9e\u9645\u7c7b\u578b\u7684\u3002\u5f53\u5bf9\u8c61\u6ca1\u6709\u6784\u9020\u6210\u529f\u65f6\uff0c\u7f16\u8bd1\u5668\u65e0\u6cd5\u77e5\u9053\u5bf9\u8c61\u5b9e\u9645\u7c7b\u578b\u662f\u8be5\u7c7b\u672c\u8eab\u8fd8\u662f\u8be5\u7c7b\u7684\u6d3e\u751f\u7c7b\uff0c\u6216\u8005\u66f4\u6df1\u5c42\u6b21\u7684\u6d3e\u751f\u7c7b\u30022\uff0c\u865a\u51fd\u6570\u7684\u6267\u884c\u4f9d\u8d56\u4e8e\u865a\u51fd\u6570\u8868\u3002\u800c\u865a\u51fd\u6570\u8868\u5b9e\u5728\u6784\u9020\u51fd\u6570\u4e2d\u8fdb\u884c\u521d\u59cb\u5316\u5de5\u4f5c\u7684\u3002\u6784\u9020\u5bf9\u8c61\u65f6\uff0c\u865a\u51fd\u6570\u8868\u8fd8\u6ca1\u6709\u88ab\u521d\u59cb\u5316\u3002\uff09&nbsp;\n\t<\/li>\n<li>\n\t\t\u9759\u6001\u6210\u5458\u51fd\u6570\u4e0d\u80fd\u4f5c\u4e3a\u865a\u51fd\u6570\u3002\uff08\u9759\u6001\u6210\u5458\u51fd\u6570\u6ca1\u6709this\u6307\u9488\uff09&nbsp;\n\t<\/li>\n<li>\n\t\t\u8d4b\u503c\u8fd0\u7b97\u7b26\u4e0d\u5efa\u8bae\u4f5c\u4e3a\u865a\u51fd\u6570\u3002\n\t<\/li>\n<\/ol>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=1284\">c++ \u591a\u6001<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u7f51\u4e0a\u5173\u4e8eC++\u7684\u6587\u7ae0\u6ca1\u6709 java \u7684\u591a\uff0c\u8fd9\u548c java \u5927\u591a\u6570\u6846\u67b6\u90fd\u5f00\u6e90\u7684\u5173\u7cfb\u5bc6\u5207\u76f8\u5173\u3002\u4eca\u5929\u4e3a\u5927\u5bb6\u5206\u4eab\u4e00\u7bc7C [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118],"tags":[1015,633,1021,1023,1022,632],"class_list":["post-1284","post","type-post","status-publish","format-standard","hentry","category-ndisdevelop","tag-c","tag-633","tag-1021","tag-1023","tag-1022","tag-632"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1284"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1284\/revisions"}],"predecessor-version":[{"id":1285,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1284\/revisions\/1285"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}