C
Chor Lit
I read Nicolai and David's book "C++ templates" and they mention, on
page 99, that every template must have a name that is unique within its
scope. The following is the example they gave:
int C;
class C; //ok: class names & nonclass names are in a different
"space"
int X;
template < typename T>
class X; //Error:conflict with variable X
struct S;
template <typename T>
class S; //Error:conflict with struct S
Can anyone explain why does template names must be unique ? What is the
rationale behind this restriction imposed by the language ? Since int C
and class C can share the same name, I don't see why the name 'X' and
'S' above can raise any conflict.
Thanks.
page 99, that every template must have a name that is unique within its
scope. The following is the example they gave:
int C;
class C; //ok: class names & nonclass names are in a different
"space"
int X;
template < typename T>
class X; //Error:conflict with variable X
struct S;
template <typename T>
class S; //Error:conflict with struct S
Can anyone explain why does template names must be unique ? What is the
rationale behind this restriction imposed by the language ? Since int C
and class C can share the same name, I don't see why the name 'X' and
'S' above can raise any conflict.
Thanks.