In the sample:
#include
using namespace std;
class B
{
public:
virtual void pvf() = 0;
};
template
class D : public B
{
p
You need to reimplement it because D
and D
are totally unrelated classes (they just happen to "share the name"). That's just how templates work.
If you want the classes to share construction code, just put that code inside B::B
(i.e. the same thing you do every time you want to reuse code in different branches of the same hierarchy: move the code up and let inheritance handle the rest).