From aa9fe29fbd155ccaf0eed054e915936f45d952ae Mon Sep 17 00:00:00 2001 From: huihut Date: Sat, 29 Feb 2020 22:46:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BF=AE=E6=94=B9=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/huihut/interview/pull/57 --- README.md | 2 +- docs/README.md | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e50b4b7..c7cb2e7 100644 --- a/README.md +++ b/README.md @@ -1152,7 +1152,7 @@ class Plane : public Flyable // 飞机 { public: void carry() {...} // 运输 - virtual void take off() {...} + virtual void takeoff() {...} virtual void land() {...} }; diff --git a/docs/README.md b/docs/README.md index 7910aba..bc9fdf4 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1093,6 +1093,9 @@ catch (bad_cast b) { typeid、type_info 使用 ```cpp +#include +using namespace std; + class Flyable // 能飞的 { public: @@ -1105,12 +1108,13 @@ public: void foraging() {...} // 觅食 virtual void takeoff() {...} virtual void land() {...} + virtual ~Bird(){} }; class Plane : public Flyable // 飞机 { public: void carry() {...} // 运输 - virtual void take off() {...} + virtual void takeoff() {...} virtual void land() {...} }; @@ -1126,7 +1130,7 @@ private: ... }; -class doSomething(Flyable *obj) // 做些事情 +void doSomething(Flyable *obj) // 做些事情 { obj->takeoff(); @@ -1139,7 +1143,15 @@ class doSomething(Flyable *obj) // 做些事情 } obj->land(); -}; +} + +int main(){ + Bird *b = new Bird(); + doSomething(b); + delete b; + b = nullptr; + return 0; +} ``` @@ -1434,14 +1446,14 @@ typedef struct { * 问题的分解 * 问题规模的分解 * 折半查找(递归) -* 归并查找(递归) +* 归并排序(递归) * 快速排序(递归) #### 递归与迭代 * 迭代:反复利用变量旧值推出新值 * 折半查找(迭代) -* 归并查找(迭代) +* 归并排序(迭代) #### 广义表 -- GitLab