i cannot find one good example...any ideas?
i cannot find one good example...any ideas?
Remember that a class has to inherit from a fully defined type, so the follwing are valid:
The following is invalid.Code:template<class T> struct A { }; template<class T> struct B : public A<T> { }; struct C : public A<int> { };
Code:template<class T> struct A { }; struct B : public A { };
I highly recommend C++ Templates: The Complete Guide
by David Vandevoorde and Nicolai M. Josuttis.
Kuphryn
You can also do
Code:template<typename T> class A : public T { };
interface class is a composite of inherited class (inherited class is data mem of interface).
inherited class inherits base class (which is not template, however may be ANY class).
intefarce class doesn't necessarily need to be a template, except that one of it's data members (inherited class) is a template.
anyway..is this right?
Code:class Base //not template { }; template<class T> //T will be Base (for this example, although base could be ANY class) class InheritedClass : public T { }; template<class T> class InterfaceClass { InheritedClass<T> *ptr; //is this correct? };