This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: classes and templates correct order.


> 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.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]