{"id":2049,"date":"2023-01-15T21:14:31","date_gmt":"2023-01-15T13:14:31","guid":{"rendered":"https:\/\/courtship.top\/?p=2049"},"modified":"2023-01-15T21:14:31","modified_gmt":"2023-01-15T13:14:31","slug":"%e5%9f%ba%e7%a1%80%e4%b8%8d%e8%a1%8c%e8%80%8c%e6%af%ab%e4%b8%8d%e5%9c%a8%e6%84%8f%e7%9a%84%e7%bb%86%e8%8a%82-c%e4%b8%89%e7%a7%8d%e5%ae%9e%e4%be%8b%e5%8c%96%e7%9a%84%e6%96%b9%e5%bc%8f%e5%92%8c","status":"publish","type":"post","link":"https:\/\/courtship.top\/index.php\/2023\/01\/15\/%e5%9f%ba%e7%a1%80%e4%b8%8d%e8%a1%8c%e8%80%8c%e6%af%ab%e4%b8%8d%e5%9c%a8%e6%84%8f%e7%9a%84%e7%bb%86%e8%8a%82-c%e4%b8%89%e7%a7%8d%e5%ae%9e%e4%be%8b%e5%8c%96%e7%9a%84%e6%96%b9%e5%bc%8f%e5%92%8c\/","title":{"rendered":"\u57fa\u7840\u4e0d\u884c\u800c\u6beb\u4e0d\u5728\u610f\u7684\u7ec6\u8282-C++\u4e09\u79cd\u5b9e\u4f8b\u5316\u7684\u65b9\u5f0f\u548c\u4e0d\u540c"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u9009\u81eaCSDN\uff1a<a class=\"\" rel=\"noreferrer noopener\" href=\"https:\/\/blog.csdn.net\/bitcarmanlee\" target=\"_blank\" rel=\"nofollow\" >bitcarmanlee<\/a><\/p>\n<cite>http:\/\/t.csdn.cn\/vd2rN<\/cite><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u79cd\u5b9e\u4f8b\u5316\u65b9\u5f0f<\/h2>\n\n\n\n<p>\u521b\u5efa\u7c7b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Person {\n    private:\n      int age;\n      string name;\n    public:\n        Person() {\n            cout&lt;&lt;\"this is construct~\";\n        }\n        Person(int age, string name) {\n            this->age = age;\n            this->name = name;\n            cout&lt;&lt;\"name is: \"&lt;&lt;name&lt;&lt;\", age is: \"&lt;&lt;age&lt;&lt;endl;\n        }\n};\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u9690\u5f0f\u521b\u5efa<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Person p1;\ncout&lt;&lt;endl;\nPerson p2(18, \"lili\");\ncout&lt;&lt;endl;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u663e\u793a\u521b\u5efa<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Person p3 = Person();\ncout&lt;&lt;endl;\nPerson p4 = Person(16, \"xx\");\ncout&lt;&lt;endl;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u7528new\u521b\u5efa<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Person *p5 = new Person();\ncout&lt;&lt;endl;\nPerson *p6 = new Person(14, \"yy\");<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u79cd\u65b9\u5f0f\u7684\u533a\u522b<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>new\u51fa\u6765\u7684\u5bf9\u8c61\u5fc5\u987b\u8981\u7528\u6307\u9488\u63a5\u6536\uff0c\u5e76\u4e14\u9700\u8981\u663e\u5f0fdelete\u9500\u6bc1\u5bf9\u8c61\u91ca\u653e\u5185\u5b58\u3002<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5185\u5b58\u4f4d\u7f6e\u4e0d\u540c\u3002\n<ul class=\"wp-block-list\">\n<li>\u5bf9\u4e8e\u9690\u5f0f\u58f0\u660e Person p1; p1\u5bf9\u8c61\u4f4d\u4e8e\u6808\u7a7a\u95f4\u3002<\/li>\n\n\n\n<li>Person *p5 = new Person(); p5\u5bf9\u8c61\u4f4d\u4e8e\u5806\u7a7a\u95f4\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5185\u5b58\u5206\u914d\u65f6\u95f4\u4e0d\u540c\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u9690\u5f0f\u521b\u5efa\u5bf9\u8c61\u7684\u65f6\u5019\uff0c\u521b\u5efa\u652f\u51fa\u5c31\u5df2\u7ecf\u5206\u914d\u4e86\u5185\u5b58\u3002<\/li>\n\n\n\n<li>\u800c\u4f7f\u7528new\u7684\u65b9\u5f0f\uff0c\u5982\u679c\u5bf9\u8c61\u6ca1\u6709\u521d\u59cb\u5316\uff0c\u6b64\u65f6\u6ca1\u6709\u5206\u914d\u5185\u5b58\u7a7a\u95f4\uff0c\u4e5f\u65e0\u6cd5delete\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>Person *p = NULL;\ndelete p;<\/code><\/pre>\n\n\n\n<p>\u4e0a\u8ff0\u8bed\u53e5\u5982\u679c\u6267\u884c\uff0c\u4f1a\u6709\u5404\u79cd\u610f\u60f3\u4e0d\u5230\u7684\u60c5\u51b5\u53d1\u751f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9690\u5f0f\u58f0\u660e\u7684\u5bf9\u8c61\u662f\u5c40\u90e8\u53d8\u91cf\uff0c\u51fa\u4e86\u51fd\u6570\u5c31\u6ca1\u6709\u4e86\u3002\u800cnew\u51fa\u6765\u7684\u6307\u9488\u5bf9\u8c61\u53ef\u4ee5\u5728\u65b9\u6cd5\u4e4b\u95f4\u4f20\u9012\uff0c\u4e14\u8be5\u6307\u9488\u5bf9\u8c61\u6240\u6307\u5411\u7684\u5806\u4e2d\u7684\u5bf9\u8c61\u5b9e\u4f8b\u4ecd\u7136\u5b58\u5728\u3002<\/li>\n\n\n\n<li>\u9891\u7e41\u8c03\u7528\u573a\u5408\u5e76\u4e0d\u9002\u5408new\uff0c\u5c31\u50cfnew\u7533\u8bf7\u548c\u91ca\u653e\u5185\u5b58\u4e00\u6837\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u9009\u81eaCSDN\uff1abitcarmanlee http:\/\/t.csdn.cn\/vd2rN \u4e09\u79cd\u5b9e\u4f8b\u5316\u65b9\u5f0f \u521b\u5efa\u7c7b \u9690\u5f0f\u521b\u5efa \u663e\u793a\u521b\u5efa  &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[22],"tags":[],"class_list":["post-2049","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts\/2049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/comments?post=2049"}],"version-history":[{"count":0,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts\/2049\/revisions"}],"wp:attachment":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/media?parent=2049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/categories?post=2049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/tags?post=2049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}