Show: Delphi C++
Display Preferences

RINF -- Redefining an Inherited Nonvirtual Function

From RAD Studio
Jump to: navigation, search

Go Up to C++ Audits

Description

This rule helps you to avoid redefining an inherited nonvirtual function. In most cases, overriding a nonvirtual function is a serious mistake and it can have grave consequences. The audit looks for such dangerous code and warns you.

Incorrect

 class Car {
 public:
   void fooBar();
 };
 
 class Truck : public Car {
 public:
   void fooBar();
 };

Correct

 class Car  {
 public:
   virtual void fooBar();
 };
 
 class Truck : public Car {
 public:
   void fooBar();
 };

See Also

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance