OPM -- Overriding Private Method

From RAD Studio
Jump to: navigation, search

Go Up to C++ Audits

Description

A subclass should not contain a method with the same name and signature as in a superclass if these methods are declared to be private. If this situation is detected, a warning message is generated.

Incorrect

 class Window {
   void init() {
     ...
   }
 };
 
 class Button : public Window {
   void init() {
      ...
   }
 };

Correct

 class Window {
   void initWindow() {
      ...
   }
 };
 
 class Button : public Window {
   void initButton() {
      ...
   }
 };

See Also