Skip to content

Commit b36768e

Browse files
committed
fixed some typos in design_virtual.md
1 parent d02f81d commit b36768e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

docs/design_virtual.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ struct FilterInputerAdapter {
482482

483483
```cpp
484484
struct FilterStrategy {
485-
virtual bool shouldDrop(int value) = 0; // 返回 true 表示该值应该被丢弃
485+
virtual bool shouldPass(int value) = 0; // 返回 true 表示该值应该被保留
486486
};
487487

488488
struct FilterStrategyAbove : FilterStrategy { // 大于一定值(threshold)才能通过
@@ -732,7 +732,6 @@ void player(Gun *gun) {
732732

733733
player(new GunWithBullet<AK47Bullet>());
734734
player(new GunWithBullet<MagicBullet>());
735-
};
736735
```
737736
738737
这样就不必每次添加新子弹类型时,都得新建一个相应的枪类型了,进一步避免了代码重复。可见模板元编程完全可与传统面向对象强强联手。
@@ -1068,7 +1067,7 @@ struct Sprite {
10681067
virtual void draw(glm::vec3 position) = 0;
10691068
};
10701069

1071-
struct FireSprite {
1070+
struct FireSprite : Sprite {
10721071
vector<char> fireTexture;
10731072

10741073
FireSprite() : fireTexture(loadTexture("fire.jpg")) {}
@@ -1078,7 +1077,7 @@ struct FireSprite {
10781077
}
10791078
};
10801079

1081-
struct IceSprite { // 假如寒冰弹需要两张贴图,也没问题!因为虚接口类允许子类有不同的成员,不同的结构体大小
1080+
struct IceSprite : Sprite { // 假如寒冰弹需要两张贴图,也没问题!因为虚接口类允许子类有不同的成员,不同的结构体大小
10821081
vector<char> iceTexture1;
10831082
vector<char> iceTexture2;
10841083

0 commit comments

Comments
 (0)