Chapter 7.4.1 of the book C++ Primer says the following:
Ordinarily, an inner scope can redefine a name from an outer scope even if that name has already been used in the inner scope. However, in a class, if a member uses a name from an outer scope and that name is a type, then the class may not subsequently redefine that name
The word subsequently makes me think that it is only an error to redefine a type name after it has been used in the class. However, two paragraphs later it says:
Although it is an error to redefine a type name, compilers are not required to diagnose this error.
Does this mean that it is an error to redefine a type name even before it has been used in a class?
It seems that the quote refers to the following case
That is the code is ill-formed due to the redeclaration of the name
Twithin the class definition that was already used in the declaration of the data membera.If you will just write
then this code is correct. The name
Tis not used as a type specifier in declarations of members of the class A.