Consider redeclaring a pure virtual member function in a derived class:
struct A { virtual int Test() = 0; }; struct B : A { virtual int Test() = 0; // Can this line be safely removed? Does it serve any purpose? }; struct C : B { virtual int Test() { return 42; } };
As far as I understand, once a member function is virtual in a base class, it is virtual forever in all derived classes.
And if a class is abstract (has a pure virtual member function), then it's okay to derive from it and not implement it...it just means that you are creating another abstract class.
There doesn't seem to be a way to say anything special about B::Test or target it specifically. It IS A::Test which, for an object of type C IS C::Test.
So I think the declaration made in B of Test is useless because it inherits from A and it's pointless to redeclare it as pure virtual ... it already is pure virtual. Am I missing anything? Does the declaration of Test in struct B as shown actually allow for anything different than if it were removed? Is there a situation where it would matter?
And I'm only talking about redeclaring a pure virtual function as pure virtual again in a derived class.