override specifier
From cppreference.com
Specifies that a virtual function overrides another virtual function.
Contents |
[edit] Syntax
function_declaration override ; | |||||||||
This section is incomplete Reason: function_declaration is probably wrong terminology |
[edit] Explanation
In a method declaration, override specifies that the function must be overriding a base class method.
override is an identifier with a special meaning when used after function declaration, otherwise it's not reserved.
[edit] Example
struct A { virtual void foo(); void bar(); }; struct B : A { void foo() const override; // Error: Has a different signature from A::foo void foo() override; // OK: base class contains a virtual function with the same signature void bar() override; // Error: B::bar doesn't override because A::bar is not virtual };
[edit] See also
- final specifier (since C++11)