warn_no_explicit_virtual

Controls the issuing of warnings if an overriding function is not declared with a virtual keyword.

Syntax

#pragma warn_no_explicit_virtual on | off | reset

Targets
All platforms.
Remarks

Listing 10.42 shows an example.

Listing 10.42 Example of warn_no_explicit_virtual pragma

#pragma warn_no_explicit_virtual on

struct A {
virtual void f();
};

struct B {
void f(); // WARNING: override ‘B::f()’ is declared
// without ’virtual’ keyword
}

TIP This warning is not required by the ISO C++ standard, but can help you track down unwanted overrides.

This pragma does not correspond to any panel setting. To check this setting, use __option (warn_no_explicit_virtual), described in Checking Settings. The default setting is off.