classes and templates correct order.

Ingo Krabbe ikrabbe@earthling.net
Sat Jun 9 01:01:00 GMT 2001


> This does not work..
>
> class A {
>  B<int> a;
>  ... etc ..
> };
>
> template <class T > B {
> ...etc..
> };
>

It is because of B<int> is a class and template <class T> B is a
template and a template is no class ! You can define

template <class T, class X /*B<int>*/ >
class A
{
}

Hmm, I thin there are other solutions but I can't remeber. The above
soultion hours C++ and OO. Using templates you have to think about the
time a type is only a template or comes to live as a specific class.
B<int> defines the template B without knowing something about B. I think
there is a constructions which can be used to define it forwardly but I
think the given solution with an extra argument is better especially with
partly specializing code

template <class T> class A<T, B<int>> ...


CU INGO.





More information about the Gcc-help mailing list