Skip to content

Commit

Permalink
fix: indent (changkun#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
baixiangcpp authored and changkun committed Feb 20, 2019
1 parent 818a848 commit 07badc8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions book/zh-cn/02-usability.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,8 @@ int main() {
```cpp
struct Base {
virtual void foo();
};
struct SubClass: Base {
};
struct SubClass: Base {
void foo();
};
```
Expand All @@ -840,11 +840,11 @@ C++11 引入了 `override` 和 `final` 这两个关键字来防止上述情形

```cpp
struct Base {
virtual void foo(int);
virtual void foo(int);
};
struct SubClass: Base {
virtual void foo(int) override; // 合法
virtual void foo(float) override; // 非法, 父类没有此虚函数
virtual void foo(int) override; // 合法
virtual void foo(float) override; // 非法, 父类没有此虚函数
};
```
Expand All @@ -854,7 +854,7 @@ virtual void foo(float) override; // 非法, 父类没有此虚函数
```cpp
struct Base {
virtual void foo() final;
virtual void foo() final;
};
struct SubClass1 final: Base {
}; // 合法
Expand All @@ -863,7 +863,7 @@ struct SubClass2 : SubClass1 {
}; // 非法, SubClass1 已 final
struct SubClass3: Base {
void foo(); // 非法, foo 已 final
void foo(); // 非法, foo 已 final
};
```

Expand Down

0 comments on commit 07badc8

Please sign in to comment.