From baf036d9b52dd582665c1d996ed331946407a804 Mon Sep 17 00:00:00 2001 From: huihut Date: Wed, 2 May 2018 11:35:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=8A=A8=E6=80=81=E5=A4=9A=E6=80=81?= =?UTF-8?q?=EF=BC=88=E6=99=9A=E7=BB=91=E5=AE=9A=EF=BC=89=E4=BE=8B=E5=AD=90?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E8=99=9A=E6=9E=90=E6=9E=84=E5=92=8Cdelete?= =?UTF-8?q?=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 6a388f6..961a89a 100644 --- a/README.md +++ b/README.md @@ -515,6 +515,7 @@ public: { ... } + virtual ~Shape(); }; class Circle : public Shape // 圆形类 { @@ -534,6 +535,10 @@ int main() Shape * shape2 = new Rect(5.0, 6.0); shape1->calcArea(); // 调用圆形类里面的方法 shape2->calcArea(); // 调用矩形类里面的方法 + delete shape1; + shape1 = nullptr; + delete shape2; + shape2 = nullptr; return 0; } ```