Even if D comes from B, and therefore you can call f () on an instance of D, this does not mean that you do not need to put the declaration in the header.
Any function you implement must be explicitly declared in the header.
You do not need, however, to put your implementation there. Just
class D : public B { public: void f(); };
and you can choose whether to include the word "virtual"
Cashcow
source share