Topic: can template classes derived from..


Author: David Welch <74663.2374@CompuServe.COM>
Date: 28 Aug 1994 20:13:59 GMT
Raw View
Yes,  templates may be inherited.  The following should work ok:

template< class T > class Foo
{
    T*  tvector;
    int tvcount;

public:
    Foo( int );
};

template< class T > class Bar : public Foo< T >
{
    T  work_T;
public:
    Bar( int );
};

Remember that each Foo< T > is a different type i.e.

    Bar< int > intBar;
    Bar< double > dblBar;
    Foo< int > * pFoo = &dblBar;    // error