{"id":20,"date":"2021-11-18T21:09:15","date_gmt":"2021-11-18T13:09:15","guid":{"rendered":"https:\/\/lmceric.top\/?p=20"},"modified":"2021-11-18T21:12:04","modified_gmt":"2021-11-18T13:12:04","slug":"coop%e5%af%b9%e8%b1%a1%e5%92%8c%e7%b1%bb","status":"publish","type":"post","link":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/","title":{"rendered":"C++OOP\u5bf9\u8c61\u548c\u7c7b"},"content":{"rendered":"\n<p>\u672c\u6587\u5c06\u4ece\u5165\u95e8\u7684\u89d2\u5ea6\u4ecb\u7ecdC++OOP\u4e2d\u7684\u7c7b\u548c\u5bf9\u8c61\uff0c\u4e8b\u5b9e\u4e0aC++\u7684\u7c7b\u548c\u5bf9\u8c61\u8fdc\u8fdc\u4e0d\u6b62\u672c\u6587\u6240\u4ecb\u7ecd\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u4e0d\u8fc7\u5982\u679c\u4f60\u611f\u5174\u8da3\uff0c\u6211\u4f1a\u628a\u5176\u4ed6\u7684\u5185\u5bb9\u9010\u4e00\u901a\u8fc7\u6587\u7ae0\u7684\u5f62\u5f0f\u4ecb\u7ecd\u7ed9\u4f60\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u9884\u5907\u77e5\u8bc6<\/h2>\n\n\n\n<p>\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff08OOP\uff09\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u3001\u8bbe\u8ba1\u7a0b\u5e8f\u7684\u6982\u5ff5\u6027\u65b9\u6cd5\uff0cC++\u901a\u8fc7\u4e00\u4e9b\u7279\u6027\u6539\u8fdb\u4e86C\u8bed\u8a00\uff0c\u4f7f\u5f97\u5e94\u7528\u8fd9\u79cd\u65b9\u6cd5\u66f4\u52a0\u5bb9\u6613\u3002\u4e0b\u9762\u662f\u6700\u91cd\u8981\u7684OOP\u7279\u6027\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u62bd\u8c61<\/li><li>\u5c01\u88c5\u548c\u6570\u636e\u9690\u85cf<\/li><li>\u591a\u6001<\/li><li>\u7ee7\u627f<\/li><li>\u4ee3\u7801\u53ef\u91cd\u7528\u6027<\/li><\/ul>\n\n\n\n<p>\uff08\u6765\u81eaC++Primer Plus \u7b2c\u516d\u7248\uff0c\u4eba\u6c11\u90ae\u7535\u51fa\u7248\u793e\uff09<\/p>\n\n\n\n<p>\u4e3a\u4e86\u5b9e\u73b0\u4e0a\u8ff0\u7279\u6027\u5e76\u628a\u5b83\u4eec\u7ed3\u5408\u5728\u4e00\u8d77\uff0cC++\u63d0\u4f9b\u4e86\u7c7b\u548c\u5bf9\u8c61\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u9996\u5148\u6765\u8ba8\u8bba\u4e00\u4e0bOOP\u3002\u867d\u7136C++\u5076\u5c14\u8ba8\u8bba\u4e86OOP\uff0c\u4f46\u66f4\u591a\u7684\u8fd8\u662f\u8bf8\u5982C\u3001Pascal\u548cBASIC\u7b49\u8bed\u8a00\u7684\u6807\u51c6\u8fc7\u7a0b\u6027\u65b9\u6cd5\u3002\u4e0b\u9762\u770b\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5b83\u5c06\u63ed\u793aOOP\u7684\u6838\u5fc3\u89c2\u70b9\u4e0e\u8fc7\u7a0b\u6027\u7f16\u7a0b\u7684\u5dee\u522b\u3002<\/p>\n\n\n\n<p>\u4e00\u822c\u6765\u8bf4\u4e00\u573a\u7403\u8d5b\u7684\u8fdb\u7403\u6570\u91cf\u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u673a\u6765\u8f85\u52a9\u8ba1\u7b97\u4f8b\u5982\u6bcf\u4e2a\u9009\u624b\u7684\u6295\u7403\u6b21\u6570\u3001\u547d\u4e2d\u7387\u7b49\u7b49\u3002\u5982\u679c\u8fd9\u4e9b\u7531C++\u7b49\u5229\u7528OOP\u7f16\u5199\u7a0b\u5e8f\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u4e00\u4e2a\u51fd\u6570\u4e2d\u8c03\u7528\u53e6\u4e00\u4e2a\u51fd\u6570\uff0c\u53ef\u4ee5\u901a\u8fc7\u6784\u5efa\u4e00\u4e2a\u7403\u961f\u7684\u7c7b\uff0c\u6216\u8005\u5efa\u7acb\u4e00\u4e2a\u7403\u5458\u7684\u5bf9\u8c61\uff0c\u901a\u8fc7\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u5b8c\u6210\u8ba1\u7b97\u3002\u800c\u53cd\u89c2\u8fc7\u7a0b\u6027\u7f16\u7a0b\uff0c\u7a0b\u5e8f\u5458\u9700\u8981\u7528\u51fd\u6570\u8c03\u7528\u53e6\u4e00\u4e2a\u51fd\u6570\u6765\u8ba1\u7b97\uff0c\u7528\u6570\u7ec4\u6216\u53d8\u91cf\u7b49\u8bb0\u5f55\u7ed3\u679c\u7b49\u7b49\u3002\uff08\u6765\u81ea\u300aC++\u8bed\u8a00\u7a0b\u5e8f\u8bbe\u8ba1\u300b\uff0c\u6e05\u534e\u5927\u5b66\u51fa\u7248\u793e\uff09<\/p>\n\n\n\n<p>\u603b\u4e4b\uff0c\u5982\u679c\u91c7\u7528\u8fc7\u7a0b\u6027\u7f16\u7a0b\uff0c\u9996\u5148\u8003\u8651\u7684\u662f\u9075\u5faa\u7684\u6b65\u9aa4\uff0c\u7136\u540e\u518d\u8003\u8651\u8fd9\u4e9b\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8eOOP\u7a0b\u5e8f\u5458\uff0c\u6211\u4eec\u9700\u8981\u8ddf\u8e2a\u7684\u5c31\u662f\u7403\u5458\uff0c\u9700\u8981\u7528\u4e00\u4e2a\u5bf9\u8c61\u8868\u793a\u6574\u4e2a\u9009\u624b\u7684\u5404\u4e2a\u65b9\u9762\u7684\u8868\u73b0\u3002<\/p>\n\n\n\n<p>\u91c7\u7528OOP\uff0c\u9996\u5148\u8981\u4ece\u7528\u6237\u7684\u89d2\u5ea6\u8003\u8651\u5bf9\u8c61\u2014\u2014\u63cf\u8ff0\u5bf9\u8c61\u6240\u9700\u7684\u6570\u636e\u4ee5\u53ca\u63cf\u8ff0\u7528\u6237\u4e0e\u6570\u636e\u4ea4\u4e92\u6240\u9700\u7684\u64cd\u4f5c\u3002\u5b8c\u6210\u63a5\u53e3\u63cf\u8ff0\u540e\uff0c\u9700\u8981\u786e\u5b9a\u5982\u4f55\u5b9e\u73b0\u63a5\u53e3\u548c\u6570\u636e\u5b58\u50a8\u3002\u6700\u540e\uff0c\u4f7f\u7528\u65b0\u7684\u8bbe\u8ba1\u65b9\u6848\u521b\u5efa\u51fa\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u62bd\u8c61\u548c\u7c7b<\/h2>\n\n\n\n<p>\u751f\u6d3b\u4e2d\u5145\u6ee1\u4e86\u590d\u6742\u6027\uff0c\u5904\u7406\u5b83\u4eec\u7684\u65b9\u6cd5\u5c31\u662f\u7b80\u5316\u548c\u62bd\u8c61\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2.1 \u6570\u636e\u62bd\u8c61<\/h3>\n\n\n\n<p>\u6570\u636e\u62bd\u8c61\u662f\u6307\uff0c\u53ea\u5411\u5916\u754c\u63d0\u4f9b\u5173\u952e\u4fe1\u606f\uff0c\u5e76\u9690\u85cf\u5176\u540e\u53f0\u7684\u5b9e\u73b0\u7ec6\u8282\uff0c\u5373\u53ea\u8868\u73b0\u5fc5\u8981\u7684\u4fe1\u606f\u800c\u4e0d\u5448\u73b0\u7ec6\u8282\u3002<\/p>\n\n\n\n<p>\u6570\u636e\u62bd\u8c61\u662f\u4e00\u79cd\u4f9d\u8d56\u4e8e\u63a5\u53e3\u548c\u5b9e\u73b0\u5206\u79bb\u7684\u7f16\u7a0b\uff08\u8bbe\u8ba1\uff09\u6280\u672f\u3002<\/p>\n\n\n\n<p>\u8ba9\u6211\u4eec\u4e3e\u4e00\u4e2a\u73b0\u5b9e\u751f\u6d3b\u4e2d\u7684\u771f\u5b9e\u4f8b\u5b50\uff0c\u6bd4\u5982\u4e00\u53f0\u7535\u89c6\u673a\uff0c\u60a8\u53ef\u4ee5\u6253\u5f00\u548c\u5173\u95ed\u3001\u5207\u6362\u9891\u9053\u3001\u8c03\u6574\u97f3\u91cf\u3001\u6dfb\u52a0\u5916\u90e8\u7ec4\u4ef6\uff08\u5982\u5587\u53ed\u3001\u5f55\u50cf\u673a\u3001DVD \u64ad\u653e\u5668\uff09\uff0c\u4f46\u662f\u60a8\u4e0d\u77e5\u9053\u5b83\u7684\u5185\u90e8\u5b9e\u73b0\u7ec6\u8282\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u60a8\u5e76\u4e0d\u77e5\u9053\u5b83\u662f\u5982\u4f55\u901a\u8fc7\u7f06\u7ebf\u63a5\u6536\u4fe1\u53f7\uff0c\u5982\u4f55\u8f6c\u6362\u4fe1\u53f7\uff0c\u5e76\u6700\u7ec8\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u8bf4\u7535\u89c6\u628a\u5b83\u7684\u5185\u90e8\u5b9e\u73b0\u548c\u5916\u90e8\u63a5\u53e3\u5206\u79bb\u5f00\u4e86\uff0c\u60a8\u65e0\u9700\u77e5\u9053\u5b83\u7684\u5185\u90e8\u5b9e\u73b0\u539f\u7406\uff0c\u76f4\u63a5\u901a\u8fc7\u5b83\u7684\u5916\u90e8\u63a5\u53e3\uff08\u6bd4\u5982\u7535\u6e90\u6309\u94ae\u3001\u9065\u63a7\u5668\u3001\u58f0\u91cf\u63a7\u5236\u5668\uff09\u5c31\u53ef\u4ee5\u64cd\u63a7\u7535\u89c6\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u8a00\u5f52\u6b63\u4f20\uff0c\u5c31 C++ \u7f16\u7a0b\u800c\u8a00\uff0cC++ \u7c7b\u4e3a<strong>\u6570\u636e\u62bd\u8c61<\/strong>\u63d0\u4f9b\u4e86\u53ef\u80fd\u3002\u5b83\u4eec\u5411\u5916\u754c\u63d0\u4f9b\u4e86\u5927\u91cf\u7528\u4e8e\u64cd\u4f5c\u5bf9\u8c61\u6570\u636e\u7684\u516c\u5171\u65b9\u6cd5\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5916\u754c\u5b9e\u9645\u4e0a\u5e76\u4e0d\u6e05\u695a\u7c7b\u7684\u5185\u90e8\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u60a8\u7684\u7a0b\u5e8f\u53ef\u4ee5\u8c03\u7528 <strong>sort()<\/strong> \u51fd\u6570\uff0c\u800c\u4e0d\u9700\u8981\u77e5\u9053\u51fd\u6570\u4e2d\u6392\u5e8f\u6570\u636e\u6240\u7528\u5230\u7684\u7b97\u6cd5\u3002\u5b9e\u9645\u4e0a\uff0c\u51fd\u6570\u6392\u5e8f\u7684\u5e95\u5c42\u5b9e\u73b0\u4f1a\u56e0\u5e93\u7684\u7248\u672c\u4e0d\u540c\u800c\u6709\u6240\u5dee\u5f02\uff0c\u53ea\u8981\u63a5\u53e3\u4e0d\u53d8\uff0c\u51fd\u6570\u8c03\u7528\u5c31\u53ef\u4ee5\u7167\u5e38\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2.2 \u7c7b<\/h3>\n\n\n\n<p>\u7c7b\u662f\u4e00\u79cd\u5c06\u62bd\u8c61\u8f6c\u6362\u4e3a\u7528\u6237\u5b9a\u4e49\u7684C++\u5de5\u5177\uff0c\u5b83\u5c06\u6570\u636e\u8868\u793a\u548c\u64cd\u63a7\u6570\u636e\u7684\u65b9\u6cd5\u7ec4\u5408\u6210\u4e00\u4e2a\u6574\u6d01\u7684\u5305\u3002\u4e0b\u9762\u6211\u4eec\u6765\u770b\u770b\u4e00\u4e2a\u8868\u793a\u80a1\u7968\u7684\u7c7b\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u6211\u4eec\u9700\u8981\u5c06\u80a1\u7968\u7684\u4e00\u80a1\u8868\u793a\u4e3a\u4e00\u4e2a\u57fa\u672c\u5355\u5143\uff0c\u5b9a\u4e49\u4e00\u4e2a\u8868\u793a\u4e00\u80a1\u80a1\u7968\u7684\u7c7b\uff0c\u7136\u800c\uff0c\u8fd9\u610f\u5473\u7740\u9700\u8981100\u4e2a\u80a1\u7968\u7684\u5355\u5143\u624d\u80fd\u6784\u6210100\u80a1\u3002\u8fd9\u5c06\u4f7f\u5de5\u4f5c\u91cf\u8d85\u6807\u3002\u76f8\u53cd\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5c06\u67d0\u4eba\u6301\u6709\u7684\u67d0\u79cd\u80a1\u7968\u4f5c\u4e3a\u4e00\u4e2a\u57fa\u672c\u5355\u5143\uff0c\u6570\u636e\u8868\u793a\u4e2d\u5305\u542b\u4ed6\u6240\u6301\u6709\u7684\u80a1\u7968\u6570\u91cf\u3002<\/p>\n\n\n\n<p>\u5177\u4f53\u5730\u8bf4\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6267\u884c\u7684\u64cd\u4f5c\u7b80\u5316\u548c\u9650\u5236\u4e3a\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u83b7\u5f97\u80a1\u7968<\/li><li>\u589e\u6301<\/li><li>\u5356\u51fa\u80a1\u7968<\/li><li>\u66f4\u65b0\u80a1\u7968\u4ef7\u683c<\/li><li>\u663e\u793a\u6301\u80a1\u4fe1\u606f<\/li><\/ul>\n\n\n\n<p>\u6839\u636e\u4e0a\u8ff0\u64cd\u4f5c\u7684\u9700\u6c42\u6765\u5b9a\u4e49stock\u7c7b\u7684\u516c\u5171\u63a5\u53e3\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u63a5\u53e3\u6765\u5b8c\u6210\u8fd9\u4e9b\u64cd\u4f5c\u3002\u800c\u5bf9\u4e8e\u9700\u8981\u50a8\u5b58\u7684\u4fe1\u606f\uff0c\u6211\u4eec\u5c06\u5b83\u518d\u6b21\u7b80\u5316\uff0c\u6211\u4eec\u6700\u7ec8\u5c06\u50a8\u5b58\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u516c\u53f8\u540d\u79f0<\/li><li>\u6240\u6301\u80a1\u7968\u6570\u91cf<\/li><li>\u6bcf\u80a1\u7684\u4ef7\u683c<\/li><li>\u80a1\u7968\u603b\u503c<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2.3 \u63a5\u53e3<\/h3>\n\n\n\n<p>\u63a5\u53e3\u662f\u4e00\u4e2a\u5171\u4eab\u7684\u6846\u67b6\uff0c\u5171\u4e24\u4e2a\u7cfb\u7edf\u4ea4\u4e92\u65f6\u4f7f\u7528\u3002\u4f8b\u5982\u5f20\u4e09\u60f3\u8981\u628a\u94f6\u884c\u91cc\u5b58\u7684\u94b1\u53d6\u8d70\uff0c\u9700\u8981\u5728\u94f6\u884c\u6216\u8005ATM\u673a\u53d6\u8d70\u4ed6\u5728\u94f6\u884c\u7cfb\u7edf\u91cc\u5b58\u7684\u94b1\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u7c7b\uff0c\u6211\u4eec\u79f0\u4e3a\u516c\u5171\u63a5\u53e3\u3002\u5728\u516c\u5171\u63a5\u53e3\u91cc\uff0c\u516c\u5171\uff08public\uff09\u662f\u4f7f\u7528\u7c7b\u7684\u7a0b\u5e8f\uff0c\u800c\u63a5\u53e3\u7531\u7a0b\u5e8f\u5458\u63d0\u4f9b\u7684\u8c03\u7528\u7c7b\u65b9\u6cd5\u7ec4\u6210\u3002\u4f8b\u5982\uff0c\u60f3\u8981\u8ba1\u7b97string\u5bf9\u8c61\u5305\u542b\u591a\u5c11\u4e2a\u5b57\u7b26\uff0c\u6211\u4eec\u65e0\u9700\u6253\u5f00\u5bf9\u8c61\uff0c\u53ea\u9700\u8981\u4f7f\u7528\u5176\u63d0\u4f9b\u7684size\u65b9\u6cd5\u3002\u65b9\u6cd5size()\u4fbf\u662f\u7528\u6237\u4e0estring\u7c7b\u4e4b\u95f4\u7684\u516c\u5171\u63a5\u53e3\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3.C++\u4e2d\u7684\u7c7b\u548c\u5bf9\u8c61<\/h2>\n\n\n\n<p>C++ \u5728 C \u8bed\u8a00\u7684\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff0cC++ \u652f\u6301\u9762\u5411\u5bf9\u8c61\u7a0b\u5e8f\u8bbe\u8ba1\u3002\u7c7b\u662f C++ \u7684\u6838\u5fc3\u7279\u6027\uff0c\u901a\u5e38\u88ab\u79f0\u4e3a\u7528\u6237\u5b9a\u4e49\u7684\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u7c7b\u7528\u4e8e\u6307\u5b9a\u5bf9\u8c61\u7684\u5f62\u5f0f\uff0c\u5b83\u5305\u542b\u4e86\u6570\u636e\u8868\u793a\u6cd5\u548c\u7528\u4e8e\u5904\u7406\u6570\u636e\u7684\u65b9\u6cd5\u3002\u7c7b\u4e2d\u7684\u6570\u636e\u548c\u65b9\u6cd5\u79f0\u4e3a\u7c7b\u7684\u6210\u5458\u3002\u51fd\u6570\u5728\u4e00\u4e2a\u7c7b\u4e2d\u88ab\u79f0\u4e3a\u7c7b\u7684\u6210\u5458\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.1 C++\u7c7b\u7684\u5b9a\u4e49<\/h3>\n\n\n\n<p>\u5b9a\u4e49\u4e00\u4e2a\u7c7b\uff0c\u672c\u8d28\u4e0a\u662f\u5b9a\u4e49\u4e00\u4e2a\u6570\u636e\u7c7b\u578b\u7684\u84dd\u56fe\u3002\u8fd9\u5b9e\u9645\u4e0a\u5e76\u6ca1\u6709\u5b9a\u4e49\u4efb\u4f55\u6570\u636e\uff0c\u4f46\u5b83\u5b9a\u4e49\u4e86\u7c7b\u7684\u540d\u79f0\u610f\u5473\u7740\u4ec0\u4e48\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b83\u5b9a\u4e49\u4e86\u7c7b\u7684\u5bf9\u8c61\u5305\u62ec\u4e86\u4ec0\u4e48\uff0c\u4ee5\u53ca\u53ef\u4ee5\u5728\u8fd9\u4e2a\u5bf9\u8c61\u4e0a\u6267\u884c\u54ea\u4e9b\u64cd\u4f5c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.runoob.com\/wp-content\/uploads\/2015\/05\/cpp-classes-objects-2020-12-10-11.png\" alt=\"C++\u7c7b\u7684\u7ed3\u6784\"\/><\/figure>\n\n\n\n<p>\u7c7b\u5b9a\u4e49\u662f\u4ee5\u5173\u952e\u5b57 <strong>class<\/strong> \u5f00\u5934\uff0c\u540e\u8ddf\u7c7b\u7684\u540d\u79f0\u3002\u7c7b\u7684\u4e3b\u4f53\u662f\u5305\u542b\u5728\u4e00\u5bf9\u82b1\u62ec\u53f7\u4e2d\u3002\u7c7b\u5b9a\u4e49\u540e\u5fc5\u987b\u8ddf\u7740\u4e00\u4e2a\u5206\u53f7\u6216\u4e00\u4e2a\u58f0\u660e\u5217\u8868\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u4f7f\u7528\u5173\u952e\u5b57 <strong>class<\/strong> \u5b9a\u4e49 Box \u6570\u636e\u7c7b\u578b\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Box { &nbsp; <br> &nbsp; &nbsp;public: &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp;double length; &nbsp; \/\/ \u76d2\u5b50\u7684\u957f\u5ea6 &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp;double breadth; &nbsp;\/\/ \u76d2\u5b50\u7684\u5bbd\u5ea6 &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp;double height; &nbsp; \/\/ \u76d2\u5b50\u7684\u9ad8\u5ea6 <br>};<\/pre>\n\n\n\n<p>\u5173\u952e\u5b57<code>public<\/code>\u786e\u5b9a\u4e86\u7c7b\u6210\u5458\u7684\u8bbf\u95ee\u5c5e\u6027\u3002\u5728\u7c7b\u5bf9\u8c61\u4f5c\u7528\u57df\u5185\uff0c\u516c\u5171\u6210\u5458\u5728\u7c7b\u7684\u5916\u90e8\u662f\u53ef\u8bbf\u95ee\u7684\u3002\u60a8\u4e5f\u53ef\u4ee5\u6307\u5b9a\u7c7b\u7684\u6210\u5458\u4e3a <code>private<\/code>\u6216 <code>protected<\/code>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.2 C++\u5bf9\u8c61\u7684\u5b9a\u4e49<\/h3>\n\n\n\n<p>\u7c7b\u63d0\u4f9b\u4e86\u5bf9\u8c61\u7684\u84dd\u56fe\uff0c\u6240\u4ee5\u57fa\u672c\u4e0a\uff0c\u5bf9\u8c61\u662f\u6839\u636e\u7c7b\u6765\u521b\u5efa\u7684\u3002\u58f0\u660e\u7c7b\u7684\u5bf9\u8c61\uff0c\u5c31\u50cf\u58f0\u660e\u57fa\u672c\u7c7b\u578b\u7684\u53d8\u91cf\u4e00\u6837\u3002\u4e0b\u9762\u7684\u8bed\u53e5\u58f0\u660e\u4e86\u7c7b Box \u7684\u4e24\u4e2a\u5bf9\u8c61\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Box Box1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u58f0\u660e Box1\uff0c\u7c7b\u578b\u4e3a Box<br>Box Box2; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u58f0\u660e Box2\uff0c\u7c7b\u578b\u4e3a Box<\/pre>\n\n\n\n<p>\u5bf9\u8c61 Box1 \u548c Box2 \u90fd\u6709\u5b83\u4eec\u5404\u81ea\u7684\u6570\u636e\u6210\u5458\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.3 C++\u8bbf\u95ee\u6570\u636e\u6210\u5458<\/h3>\n\n\n\n<p>\u7c7b\u7684\u5bf9\u8c61\u7684\u516c\u5171\u6570\u636e\u6210\u5458\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6210\u5458\u8bbf\u95ee\u8fd0\u7b97\u7b26<code>.<\/code>\u6765\u8bbf\u95ee\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.runoob.com\/wp-content\/uploads\/2015\/05\/cpp-classes-objects-2020-12-10-11-2.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\u80fd\u5e2e\u52a9\u4f60\u7406\u89e3\u4e0a\u8ff0\u6982\u5ff5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include &lt;iostream&gt;<br> <br>using namespace std;<br> <br>class Box<br>{<br> &nbsp; public:<br> &nbsp; &nbsp; &nbsp;double length; &nbsp; \/\/ \u957f\u5ea6<br> &nbsp; &nbsp; &nbsp;double breadth; &nbsp;\/\/ \u5bbd\u5ea6<br> &nbsp; &nbsp; &nbsp;double height; &nbsp; \/\/ \u9ad8\u5ea6<br> &nbsp; &nbsp; &nbsp;\/\/ \u6210\u5458\u51fd\u6570\u58f0\u660e<br> &nbsp; &nbsp; &nbsp;double get(void);<br> &nbsp; &nbsp; &nbsp;void set( double len, double bre, double hei );<br>};<br>\/\/ \u6210\u5458\u51fd\u6570\u5b9a\u4e49<br>double Box::get(void)<br>{<br> &nbsp; &nbsp;return length * breadth * height;<br>}<br> <br>void Box::set( double len, double bre, double hei)<br>{<br> &nbsp; &nbsp;length = len;<br> &nbsp; &nbsp;breadth = bre;<br> &nbsp; &nbsp;height = hei;<br>}<br>int main( )<br>{<br> &nbsp; Box Box1; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u58f0\u660e Box1\uff0c\u7c7b\u578b\u4e3a Box<br> &nbsp; Box Box2; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u58f0\u660e Box2\uff0c\u7c7b\u578b\u4e3a Box<br> &nbsp; Box Box3; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u58f0\u660e Box3\uff0c\u7c7b\u578b\u4e3a Box<br> &nbsp; double volume = 0.0; &nbsp; &nbsp; \/\/ \u7528\u4e8e\u5b58\u50a8\u4f53\u79ef<br> <br> &nbsp; \/\/ box 1 \u8be6\u8ff0<br> &nbsp; Box1.height = 5.0; <br> &nbsp; Box1.length = 6.0; <br> &nbsp; Box1.breadth = 7.0;<br> <br> &nbsp; \/\/ box 2 \u8be6\u8ff0<br> &nbsp; Box2.height = 10.0;<br> &nbsp; Box2.length = 12.0;<br> &nbsp; Box2.breadth = 13.0;<br> <br> &nbsp; \/\/ box 1 \u7684\u4f53\u79ef<br> &nbsp; volume = Box1.height * Box1.length * Box1.breadth;<br> &nbsp; cout &lt;&lt; \"Box1 \u7684\u4f53\u79ef\uff1a\" &lt;&lt; volume &lt;&lt;endl;<br> <br> &nbsp; \/\/ box 2 \u7684\u4f53\u79ef<br> &nbsp; volume = Box2.height * Box2.length * Box2.breadth;<br> &nbsp; cout &lt;&lt; \"Box2 \u7684\u4f53\u79ef\uff1a\" &lt;&lt; volume &lt;&lt;endl;<br> <br> <br> &nbsp; \/\/ box 3 \u8be6\u8ff0<br> &nbsp; Box3.set(16.0, 8.0, 12.0); <br> &nbsp; volume = Box3.get(); <br> &nbsp; cout &lt;&lt; \"Box3 \u7684\u4f53\u79ef\uff1a\" &lt;&lt; volume &lt;&lt;endl;<br> &nbsp; return 0;<br>}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.4 C++\u7c7b\u6210\u5458\u51fd\u6570<\/h3>\n\n\n\n<p>\u7c7b\u7684\u6210\u5458\u51fd\u6570\u662f\u6307\u90a3\u4e9b\u628a\u5b9a\u4e49\u548c\u539f\u578b\u5199\u5728\u7c7b\u5b9a\u4e49\u5185\u90e8\u7684\u51fd\u6570\uff0c\u5c31\u50cf\u7c7b\u5b9a\u4e49\u4e2d\u7684\u5176\u4ed6\u53d8\u91cf\u4e00\u6837\u3002\u7c7b\u6210\u5458\u51fd\u6570\u662f\u7c7b\u7684\u4e00\u4e2a\u6210\u5458\uff0c\u5b83\u53ef\u4ee5\u64cd\u4f5c\u7c7b\u7684\u4efb\u610f\u5bf9\u8c61\uff0c\u53ef\u4ee5\u8bbf\u95ee\u5bf9\u8c61\u4e2d\u7684\u6240\u6709\u6210\u5458\u3002<\/p>\n\n\n\n<p>\u8ba9\u6211\u4eec\u770b\u770b\u4e4b\u524d\u5b9a\u4e49\u7684\u7c7b Box\uff0c\u73b0\u5728\u6211\u4eec\u8981\u4f7f\u7528\u6210\u5458\u51fd\u6570\u6765\u8bbf\u95ee\u7c7b\u7684\u6210\u5458\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u8bbf\u95ee\u8fd9\u4e9b\u7c7b\u7684\u6210\u5458\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Box<br>{<br> &nbsp; public:<br> &nbsp; &nbsp; &nbsp;double length; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \u957f\u5ea6<br> &nbsp; &nbsp; &nbsp;double breadth; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u5bbd\u5ea6<br> &nbsp; &nbsp; &nbsp;double height; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \u9ad8\u5ea6<br> &nbsp; &nbsp; &nbsp;double getVolume(void);\/\/ \u8fd4\u56de\u4f53\u79ef<br>};<\/pre>\n\n\n\n<p>\u6210\u5458\u51fd\u6570\u53ef\u4ee5\u5b9a\u4e49\u5728\u7c7b\u5b9a\u4e49\u5185\u90e8\uff0c\u6216\u8005\u5355\u72ec\u4f7f\u7528<strong>\u8303\u56f4\u89e3\u6790\u8fd0\u7b97\u7b26 ::<\/strong> \u6765\u5b9a\u4e49\u3002\u5728\u7c7b\u5b9a\u4e49\u4e2d\u5b9a\u4e49\u7684\u6210\u5458\u51fd\u6570\u628a\u51fd\u6570\u58f0\u660e\u4e3a<strong>\u5185\u8054<\/strong>\u7684\uff0c\u5373\u4fbf\u6ca1\u6709\u4f7f\u7528 inline \u6807\u8bc6\u7b26\u3002\u6240\u4ee5\u60a8\u53ef\u4ee5\u6309\u7167\u5982\u4e0b\u65b9\u5f0f\u5b9a\u4e49 <strong>getVolume()<\/strong> \u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Box<br>{<br> &nbsp; public:<br> &nbsp; &nbsp; &nbsp;double length; &nbsp; &nbsp; &nbsp;\/\/ \u957f\u5ea6<br> &nbsp; &nbsp; &nbsp;double breadth; &nbsp; &nbsp; \/\/ \u5bbd\u5ea6<br> &nbsp; &nbsp; &nbsp;double height; &nbsp; &nbsp; &nbsp;\/\/ \u9ad8\u5ea6<br> &nbsp; <br> &nbsp; &nbsp; &nbsp;double getVolume(void)<br> &nbsp; &nbsp;  {<br> &nbsp; &nbsp; &nbsp; &nbsp; return length * breadth * height;<br> &nbsp; &nbsp;  }<br>};<\/pre>\n\n\n\n<p>\u60a8\u4e5f\u53ef\u4ee5\u5728\u7c7b\u7684\u5916\u90e8\u4f7f\u7528<strong>\u8303\u56f4\u89e3\u6790\u8fd0\u7b97\u7b26 ::<\/strong> \u5b9a\u4e49\u8be5\u51fd\u6570\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">double Box::getVolume(void)<br>{<br> &nbsp; &nbsp;return length * breadth * height;<br>}<\/pre>\n\n\n\n<p>\u5728\u8fd9\u91cc\uff0c\u9700\u8981\u5f3a\u8c03\u4e00\u70b9\uff0c\u5728 :: \u8fd0\u7b97\u7b26\u4e4b\u524d\u5fc5\u987b\u4f7f\u7528\u7c7b\u540d\u3002\u8c03\u7528\u6210\u5458\u51fd\u6570\u662f\u5728\u5bf9\u8c61\u4e0a\u4f7f\u7528\u70b9\u8fd0\u7b97\u7b26\uff08<strong>.<\/strong>\uff09\uff0c\u8fd9\u6837\u5b83\u5c31\u80fd\u64cd\u4f5c\u4e0e\u8be5\u5bf9\u8c61\u76f8\u5173\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5b9a\u4e49\u5728\u7c7b\u4e2d\u7684\u6210\u5458\u51fd\u6570\u7f3a\u7701\u90fd\u662f\u5185\u8054\u7684\uff0c\u5982\u679c\u5728\u7c7b\u5b9a\u4e49\u65f6\u5c31\u5728\u7c7b\u5185\u7ed9\u51fa\u51fd\u6570\u5b9a\u4e49\uff0c\u90a3\u5f53\u7136\u6700\u597d\u3002\u5982\u679c\u5728\u7c7b\u4e2d\u672a\u7ed9\u51fa\u6210\u5458\u51fd\u6570\u5b9a\u4e49\uff0c\u800c\u53c8\u60f3\u5185\u8054\u8be5\u51fd\u6570\u7684\u8bdd\uff0c\u90a3\u5728\u7c7b\u5916\u8981\u52a0\u4e0a <strong>inline<\/strong>\uff0c\u5426\u5219\u5c31\u8ba4\u4e3a\u4e0d\u662f\u5185\u8054\u7684\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class A<br>{<br> &nbsp; &nbsp;public:void Foo(int x, int y) {  } \/\/ \u81ea\u52a8\u5730\u6210\u4e3a\u5185\u8054\u51fd\u6570<br>}<\/pre>\n\n\n\n<p>\u5c06\u6210\u5458\u51fd\u6570\u7684\u5b9a\u4e49\u4f53\u653e\u5728\u7c7b\u58f0\u660e\u4e4b\u4e2d\u867d\u7136\u80fd\u5e26\u6765\u4e66\u5199\u4e0a\u7684\u65b9\u4fbf\uff0c\u4f46\u4e0d\u662f\u4e00\u79cd\u826f\u597d\u7684\u7f16\u7a0b\u98ce\u683c\uff0c\u4e0a\u4f8b\u5e94\u8be5\u6539\u6210\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ \u5934\u6587\u4ef6<br>class A<br>{<br> &nbsp; &nbsp;public:<br> &nbsp; &nbsp;void Foo(int x, int y);<br>}<br>\/\/ \u5b9a\u4e49\u6587\u4ef6<br>inline void A::Foo(int x, int y){} <\/pre>\n\n\n\n<p><strong>inline \u662f\u4e00\u79cd\u7528\u4e8e\u5b9e\u73b0\u7684\u5173\u952e\u5b57<\/strong><\/p>\n\n\n\n<p>\u5173\u952e\u5b57 inline \u5fc5\u987b\u4e0e\u51fd\u6570\u5b9a\u4e49\u4f53\u653e\u5728\u4e00\u8d77\u624d\u80fd\u4f7f\u51fd\u6570\u6210\u4e3a\u5185\u8054\uff0c\u4ec5\u5c06inline \u653e\u5728\u51fd\u6570\u58f0\u660e\u524d\u9762\u4e0d\u8d77\u4efb\u4f55\u4f5c\u7528\u3002<\/p>\n\n\n\n<p>\u5982\u4e0b\u98ce\u683c\u7684\u51fd\u6570 <strong>Foo<\/strong> \u4e0d\u80fd\u6210\u4e3a\u5185\u8054\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">inline void Foo(int x, int y); \/\/ inline \u4ec5\u4e0e\u51fd\u6570\u58f0\u660e\u653e\u5728\u4e00\u8d77<br>void Foo(int x, int y){}<\/pre>\n\n\n\n<p>\u800c\u5982\u4e0b\u98ce\u683c\u7684\u51fd\u6570Foo \u5219\u6210\u4e3a\u5185\u8054\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void Foo(int x, int y);<br>inline void Foo(int x, int y) {}  \/\/ inline \u4e0e\u51fd\u6570\u5b9a\u4e49\u4f53\u653e\u5728\u4e00\u8d77<\/pre>\n\n\n\n<p>\u73b0\u5728\u6211\u4eec\u6765\u68b3\u7406\u4e00\u4e0b\u4e0a\u9762\u6240\u8bf4\u7684\u7a0b\u5e8f\uff0c\u5982\u4e0b\u6240\u793a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include &lt;iostream&gt;<br> <br>using namespace std;<br> <br>class Box<br>{<br>   public:<br>      double length;         \/\/ \u957f\u5ea6<br>      double breadth;        \/\/ \u5bbd\u5ea6<br>      double height;         \/\/ \u9ad8\u5ea6<br> <br>      \/\/ \u6210\u5458\u51fd\u6570\u58f0\u660e<br>      double getVolume(void);<br>      void setLength( double len );<br>      void setBreadth( double bre );<br>      void setHeight( double hei );<br>};<br> <br>\/\/ \u6210\u5458\u51fd\u6570\u5b9a\u4e49<br>double Box::getVolume(void)<br>{<br>    return length * breadth * height;<br>}<br> <br>void Box::setLength( double len )<br>{<br>    length = len;<br>}<br> <br>void Box::setBreadth( double bre )<br>{<br>    breadth = bre;<br>}<br> <br>void Box::setHeight( double hei )<br>{<br>    height = hei;<br>}<br> <br>\/\/ \u7a0b\u5e8f\u7684\u4e3b\u51fd\u6570<br>int main( )<br>{<br>   Box Box1;                \/\/ \u58f0\u660e Box1\uff0c\u7c7b\u578b\u4e3a Box<br>   Box Box2;                \/\/ \u58f0\u660e Box2\uff0c\u7c7b\u578b\u4e3a Box<br>   double volume = 0.0;     \/\/ \u7528\u4e8e\u5b58\u50a8\u4f53\u79ef<br> <br>   \/\/ box 1 \u8be6\u8ff0<br>   Box1.setLength(6.0); <br>   Box1.setBreadth(7.0); <br>   Box1.setHeight(5.0);<br> <br>   \/\/ box 2 \u8be6\u8ff0<br>   Box2.setLength(12.0); <br>   Box2.setBreadth(13.0); <br>   Box2.setHeight(10.0);<br> <br>   \/\/ box 1 \u7684\u4f53\u79ef<br>   volume = Box1.getVolume();<br>   cout &lt;&lt; \"Box1 \u7684\u4f53\u79ef\uff1a\" &lt;&lt; volume &lt;&lt;endl;<br> <br>   \/\/ box 2 \u7684\u4f53\u79ef<br>   volume = Box2.getVolume();<br>   cout &lt;&lt; \"Box2 \u7684\u4f53\u79ef\uff1a\" &lt;&lt; volume &lt;&lt;endl;<br>   return 0;<br>}<\/pre>\n\n\n\n<p>\u8be5\u7a0b\u5e8f\u88ab\u7f16\u8bd1\u540e\u6267\u884c\uff0c\u4f1a\u5f97\u5230\u4e0b\u5217\u8f93\u51fa<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Box1 \u7684\u4f53\u79ef\uff1a 210<br>Box2 \u7684\u4f53\u79ef\uff1a 1560<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c06\u4ece\u5165\u95e8\u7684\u89d2\u5ea6\u4ecb\u7ecdC++OOP\u4e2d\u7684\u7c7b\u548c\u5bf9\u8c61\uff0c\u4e8b&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/\">Continue reading<span class=\"screen-reader-text\">C++OOP\u5bf9\u8c61\u548c\u7c7b<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[11],"tags":[8,9,10],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-tec","tag-c","tag-oop","tag-10","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>C++OOP\u5bf9\u8c61\u548c\u7c7b - LMC\u7684\u4e2a\u4eba\u7ad9<\/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:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++OOP\u5bf9\u8c61\u548c\u7c7b - LMC\u7684\u4e2a\u4eba\u7ad9\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6587\u5c06\u4ece\u5165\u95e8\u7684\u89d2\u5ea6\u4ecb\u7ecdC++OOP\u4e2d\u7684\u7c7b\u548c\u5bf9\u8c61\uff0c\u4e8b&#8230;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/\" \/>\n<meta property=\"og:site_name\" content=\"LMC\u7684\u4e2a\u4eba\u7ad9\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-18T13:09:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-18T13:12:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.runoob.com\/wp-content\/uploads\/2015\/05\/cpp-classes-objects-2020-12-10-11.png\" \/>\n<meta name=\"author\" content=\"SimpleAstronaut\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"SimpleAstronaut\" \/>\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\":\"Article\",\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/\"},\"author\":{\"name\":\"SimpleAstronaut\",\"@id\":\"https:\\\/\\\/lmceric.top\\\/#\\\/schema\\\/person\\\/1edca9cfe5ff17dbe947c332a66ee539\"},\"headline\":\"C++OOP\u5bf9\u8c61\u548c\u7c7b\",\"datePublished\":\"2021-11-18T13:09:15+00:00\",\"dateModified\":\"2021-11-18T13:12:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/\"},\"wordCount\":61,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.runoob.com\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/cpp-classes-objects-2020-12-10-11.png\",\"keywords\":[\"C++\",\"OOP\",\"\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\"],\"articleSection\":[\"\u6280\u672f\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/\",\"url\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/\",\"name\":\"C++OOP\u5bf9\u8c61\u548c\u7c7b - LMC\u7684\u4e2a\u4eba\u7ad9\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/lmceric.top\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.runoob.com\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/cpp-classes-objects-2020-12-10-11.png\",\"datePublished\":\"2021-11-18T13:09:15+00:00\",\"dateModified\":\"2021-11-18T13:12:04+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/lmceric.top\\\/#\\\/schema\\\/person\\\/1edca9cfe5ff17dbe947c332a66ee539\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.runoob.com\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/cpp-classes-objects-2020-12-10-11.png\",\"contentUrl\":\"https:\\\/\\\/www.runoob.com\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/cpp-classes-objects-2020-12-10-11.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/2021\\\/11\\\/18\\\/20\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\\\/\\\/lmceric.top\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++OOP\u5bf9\u8c61\u548c\u7c7b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/lmceric.top\\\/#website\",\"url\":\"https:\\\/\\\/lmceric.top\\\/\",\"name\":\"LMC\u7684\u4e2a\u4eba\u7ad9\",\"description\":\"\u5b64\u5e06\u8fdc\u5f71\u78a7\u7a7a\u5c3d\uff0c\u552f\u89c1\u957f\u6c5f\u5929\u9645\u6d41\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/lmceric.top\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/lmceric.top\\\/#\\\/schema\\\/person\\\/1edca9cfe5ff17dbe947c332a66ee539\",\"name\":\"SimpleAstronaut\",\"sameAs\":[\"http:\\\/\\\/lmceric.top\"],\"url\":\"https:\\\/\\\/lmceric.top\\\/index.php\\\/author\\\/simpleastronaut\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C++OOP\u5bf9\u8c61\u548c\u7c7b - LMC\u7684\u4e2a\u4eba\u7ad9","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:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/","og_locale":"zh_CN","og_type":"article","og_title":"C++OOP\u5bf9\u8c61\u548c\u7c7b - LMC\u7684\u4e2a\u4eba\u7ad9","og_description":"\u672c\u6587\u5c06\u4ece\u5165\u95e8\u7684\u89d2\u5ea6\u4ecb\u7ecdC++OOP\u4e2d\u7684\u7c7b\u548c\u5bf9\u8c61\uff0c\u4e8b&#8230;","og_url":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/","og_site_name":"LMC\u7684\u4e2a\u4eba\u7ad9","article_published_time":"2021-11-18T13:09:15+00:00","article_modified_time":"2021-11-18T13:12:04+00:00","og_image":[{"url":"https:\/\/www.runoob.com\/wp-content\/uploads\/2015\/05\/cpp-classes-objects-2020-12-10-11.png","type":"","width":"","height":""}],"author":"SimpleAstronaut","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"SimpleAstronaut","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/#article","isPartOf":{"@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/"},"author":{"name":"SimpleAstronaut","@id":"https:\/\/lmceric.top\/#\/schema\/person\/1edca9cfe5ff17dbe947c332a66ee539"},"headline":"C++OOP\u5bf9\u8c61\u548c\u7c7b","datePublished":"2021-11-18T13:09:15+00:00","dateModified":"2021-11-18T13:12:04+00:00","mainEntityOfPage":{"@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/"},"wordCount":61,"commentCount":0,"image":{"@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/#primaryimage"},"thumbnailUrl":"https:\/\/www.runoob.com\/wp-content\/uploads\/2015\/05\/cpp-classes-objects-2020-12-10-11.png","keywords":["C++","OOP","\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b"],"articleSection":["\u6280\u672f"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/","url":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/","name":"C++OOP\u5bf9\u8c61\u548c\u7c7b - LMC\u7684\u4e2a\u4eba\u7ad9","isPartOf":{"@id":"https:\/\/lmceric.top\/#website"},"primaryImageOfPage":{"@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/#primaryimage"},"image":{"@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/#primaryimage"},"thumbnailUrl":"https:\/\/www.runoob.com\/wp-content\/uploads\/2015\/05\/cpp-classes-objects-2020-12-10-11.png","datePublished":"2021-11-18T13:09:15+00:00","dateModified":"2021-11-18T13:12:04+00:00","author":{"@id":"https:\/\/lmceric.top\/#\/schema\/person\/1edca9cfe5ff17dbe947c332a66ee539"},"breadcrumb":{"@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/#primaryimage","url":"https:\/\/www.runoob.com\/wp-content\/uploads\/2015\/05\/cpp-classes-objects-2020-12-10-11.png","contentUrl":"https:\/\/www.runoob.com\/wp-content\/uploads\/2015\/05\/cpp-classes-objects-2020-12-10-11.png"},{"@type":"BreadcrumbList","@id":"https:\/\/lmceric.top\/index.php\/2021\/11\/18\/20\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/lmceric.top\/"},{"@type":"ListItem","position":2,"name":"C++OOP\u5bf9\u8c61\u548c\u7c7b"}]},{"@type":"WebSite","@id":"https:\/\/lmceric.top\/#website","url":"https:\/\/lmceric.top\/","name":"LMC\u7684\u4e2a\u4eba\u7ad9","description":"\u5b64\u5e06\u8fdc\u5f71\u78a7\u7a7a\u5c3d\uff0c\u552f\u89c1\u957f\u6c5f\u5929\u9645\u6d41","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lmceric.top\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/lmceric.top\/#\/schema\/person\/1edca9cfe5ff17dbe947c332a66ee539","name":"SimpleAstronaut","sameAs":["http:\/\/lmceric.top"],"url":"https:\/\/lmceric.top\/index.php\/author\/simpleastronaut\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":1,"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":21,"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/posts\/20\/revisions\/21"}],"wp:attachment":[{"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lmceric.top\/index.php\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}