Rule Definition
When a virtual method is overridden then the overloads of that method in the base class are not visible from the derived class. If all overloaded functions are not brought into the derived class by overriding them or using a declaration, then you can get surprising results when calling member methods with the same name.
Remediation
Redefine the method in the child class.
Violation Code Sample
class Base
{
public:
virtual void foo( short );
virtual void foo( double );
};
class Derived : public Base
{
public:
virtual void foo( short ); // => VIOLATION foo(double) not redefined!
void bar()
{
foo( 0.1 ); // calls Derived::foo( short )!
}
};
Reference
Industrial Strength C++ 7.16
Effective C++, Item 37
Related Technologies
C++
Technical Criterion
Programming Practices - OO Inheritance and Polymorphism
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.