This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: classes and templates correct order.
- To: Roberto Diaz <rdiazmartin at vivaldi dot net dot dhis dot org>
- Subject: Re: classes and templates correct order.
- From: Ingo Krabbe <ikrabbe at earthling dot net>
- Date: Sat, 9 Jun 2001 10:06:16 +0200 (CEST)
- cc: <gcc-help at gcc dot gnu dot org>
- Reply-To: Ingo Krabbe <i dot krabbe at dokom dot net>
> 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.