I have this piece of code (contrived from my real-life trouble)
It cannot compile, complaining ExtendsB does not implement B::Run(A* a). However, it has no problems understanding the extension to A* Run();
class A { };
class ExtendsA : public A { };
class B
{
public:
virtual ~B(){}
virtual void Run(A* a) = 0;
virtual A* Run() = 0;
};
class ExtendsB : public B
{
public:
virtual ~ExtendsB(){}
// Not OK! It does not see it as an implementation of
// virtual void Run(A* a) = 0;
virtual void Run(ExtendsA* ea) {};
virtual ExtendsA* Run() { return new ExtendsA(); }; // OK
};
Why C++ allows to change the return type to a sub-class, but not the parameter type?
Is it a good rationale or just a missed point in the language specifications?