Topic: Q: templates and inheritance
Author: WI00045@wipool.wifo.uni-mannheim.de (MIHAEL MODIC)
Date: 4 Jul 1994 13:25:44 GMT Raw View
Hi,
Let s say we have the following piece of code:
template <class A>
struct tensorfn
{
....
};
tensorfn<X>; // template definition (instantiation?)
template <class B>
struct tensor : public B
{
....
};
tensor< tensorfn<X> > x;
If I want to compile this successfully in (bc++ 3.1) I have first to
define the structure template tensorfn with the same argument (X)
as by the declaration of the x variable BEFORE the tensor class
definition.
This is a bit nasty. Does someone have an idea how could be possible
to derive the structure tensor from its template argument tensorfn
and not to have to define(instantiate) the base class tensorfn<X> before ?
Maybe there could be a trick in using an additional class template or
good placed typedef s.
In fact I have this type of declaration:
tensor< tensorfn< allocator< tensorrep<double> > > > t;
Thanks in advance,
miha