Skip to content

A small discriminative modification to the nature of override and overload #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/en-us/02-usability.md
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ C++11 introduces the two keywords `override` and `final` to prevent this from ha

### override

When overriding a virtual function, introducing the `override` keyword will explicitly tell the compiler to overload, and the compiler will check if the base function has such a virtual function, otherwise it will not compile:
When overriding a virtual function, introducing the `override` keyword will explicitly tell the compiler to overload, and the compiler will check if the base function has such a virtual function with consistent function signature, otherwise it will not compile:

```cpp
struct Base {
Expand Down
2 changes: 1 addition & 1 deletion book/zh-cn/02-usability.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ C++11 引入了 `override` 和 `final` 这两个关键字来防止上述情形

#### override

当重载虚函数时,引入 `override` 关键字将显式的告知编译器进行重载,编译器将检查基函数是否存在这样的虚函数,否则将无法通过编译:
当重载虚函数时,引入 `override` 关键字将显式的告知编译器进行重载,编译器将检查基函数是否存在这样的其函数签名一致的虚函数,否则将无法通过编译:

```cpp
struct Base {
Expand Down