Can a member of a class be named the same name as its type (another class)?
问题 Trying to compile the following code on different compilers gives me two different results: struct S{}; struct T{S S;}; int main(){} As you can see, inside T , I have an object named the same as the previously defined class S . On GCC 4.7.2, I get the following error pertaining to the S S; declaration inside T : error: declaration of 'S T::S' [-fpermissive] error: changes meaning of 'S' from 'struct S' [-fpermissive] However, moving it outside of the class (or into main ) works fine: struct S