File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -1131,6 +1131,9 @@ catch (bad_cast b) {
1131
1131
typeid、type_info 使用
1132
1132
1133
1133
``` cpp
1134
+ #include < iostream>
1135
+ using namespace std ;
1136
+
1134
1137
class Flyable // 能飞的
1135
1138
{
1136
1139
public:
@@ -1143,6 +1146,7 @@ public:
1143
1146
void foraging() {...} // 觅食
1144
1147
virtual void takeoff() {...}
1145
1148
virtual void land() {...}
1149
+ virtual ~ Bird(){}
1146
1150
};
1147
1151
class Plane : public Flyable // 飞机
1148
1152
{
@@ -1164,7 +1168,7 @@ private:
1164
1168
...
1165
1169
};
1166
1170
1167
- class doSomething (Flyable *obj) // 做些事情
1171
+ void doSomething (Flyable * obj) // 做些事情
1168
1172
{
1169
1173
obj->takeoff();
1170
1174
@@ -1177,7 +1181,15 @@ class doSomething(Flyable *obj) // 做些事情
1177
1181
}
1178
1182
1179
1183
obj->land();
1180
- };
1184
+ }
1185
+
1186
+ int main(){
1187
+ Bird * b = new Bird();
1188
+ doSomething(b);
1189
+ delete b;
1190
+ b = nullptr;
1191
+ return 0;
1192
+ }
1181
1193
```
1182
1194
1183
1195
@@ -1472,13 +1484,13 @@ typedef struct {
1472
1484
* 问题的分解
1473
1485
* 问题规模的分解
1474
1486
* 折半查找(递归)
1475
- * 归并查找 (递归)
1487
+ * 归并排序 (递归)
1476
1488
* 快速排序(递归)
1477
1489
1478
1490
#### 递归与迭代
1479
1491
1480
1492
* 迭代:反复利用变量旧值推出新值
1481
- * 折半查找 (迭代)
1493
+ * 折半排序 (迭代)
1482
1494
* 归并查找(迭代)
1483
1495
1484
1496
#### 广义表
You can’t perform that action at this time.
0 commit comments