Suppose following code is given.
class A
{
public:
virtual void someMethod()
{
std::cout << "class A" << std::endl;
}
};
class B : public A
{
public:
...
virtual void someMethod() = 0;
...
};
Class B
overrides someMethod
virtual method with pure-virtual method.
The purpose of doing this might be extension of existing class which is not allowed to modify in our case class A
, but still having an abstract class B
which has to be base class for some further classes.
According to MISRA-C++ Rule 10-3-3 : Code analyzer gives a warning : Pure virtual function overrides a non pure virtual function .
But I cannot find much details about the warning. What is the side effect of the above mentioned code ? What is the bad practice here ?
UPDATE : the standard is MISRA-C++ (C++98)
final
? (C++11 10.3p4) – Mucusclass B : public A { public: virtual void someMethod() {someMethodB();} virtual void someMethodB() = 0; };
– Muliebrity