Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 1.71 KB

c26433.md

File metadata and controls

47 lines (33 loc) · 1.71 KB
description title ms.date f1_keywords helpviewer_keywords
Learn more about: Warning C26433 OVERRIDE_EXPLICITLY
Warning C26433
01/18/2017
C26433
OVERRIDE_EXPLICITLY
C26433

Warning C26433

Function should be marked with override

C++ Core Guidelines

C.128: Virtual functions should specify exactly one of virtual, override, or final

It's not required by the compiler to clearly state that a virtual function overrides its base. Not specifying override can cause subtle issues during maintenance if the virtual specification ever changes in the class hierarchy. It also lowers readability and makes an interface's polymorphic behavior less obvious. If a function is clearly marked as override, the compiler can check the consistency of the interface, and help to spot issues before they manifest themselves at run time.

Notes

This rule isn't applicable to destructors. Destructors have their own virtuality specifics.

The rule doesn't flag functions explicitly marked as final, which is itself a special variety of virtual specifier.

Warnings show up on function definitions, not declarations. It may be confusing, since definitions don't have virtual specifiers, but the warning is still correct.

Code analysis name: OVERRIDE_EXPLICITLY

Example: Implicit overriding

class Shape {
public:
    virtual void Draw() = 0;
    // ...
};

class Ellipse : public Shape {
public:
    void Draw() { // C26433
        //...
    }
};

See also

C.128: Virtual functions should specify exactly one of virtual, override, or final