However, the reason is that you're calling mPtr->output(), and in the fwd declaration there's no such method.
With templates things are different since the compiler doesn't do anything until you really need your class (and at that point you have all the info you need about the class).
And BTW, the usage is in general a little different than what you appear to be doing here (which doesn't make much sense, but I guess it's just an example). Mixin classes are used to add "common" methods to a set of classes. Typical example is adding a clone method, somehow like this:
1 2 3 4 5 6 7 8 9
template <class T>
class Cloneable
{
T* clone() const {returnnew T(); };
};
class A : public Cloneable<A>
{
};
Now A has a proper clone() method.
Maybe you want to consider nested classes instead? Google pimpl idiom.
Compilers work templates differently. C++ compilers construct the templated class on demand. In your case, it is constructed when the parsing of Deri is done. Since the compiler have parsed Deri (because it is needed to construct the template), the Base constructor can call the output() method just fine because Deri is no longer an incomplete type.
Yes, the correct way is this last form that you show, separating declaration (prototype) from definition.