Rule Definition
For a function to be picked as an override of a function in a base class, both functions must match exactly - same name, same parameters and same const/volatile qualification. If the functions only differ by the qualification, they will be seen as totally non correlated functions, and the base function will not be considered as overridden.
C++11: If you use the 'override' keyword, you will not risk a function in a derived class not matching the version in the base class.
Remediation
If the base class function must be overridden, then respect all its properties in the derived class. Otherwise, use a name that is different for the function of the derived class.
Violation Code Sample
class A
{
public:
virtual ~A();
virtual void f() const;
};
class B : public A
{
public:
virtual void f(); // Violation
};
Related Technologies
C++
Technical Criterion
Programming Practices - Unexpected Behavior
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.