class A {
public: enum class { HELLO, WORLD };
};
Having known that, inside a class
, declaring a simple enum
(rather than enum class
) is a better idea, because it's already typed with the class
identification. But still above statement is a valid C++0x
signature. Now how to access an unnamed enum class
outside ?
int i = A::HELLO; // error: ‘HELLO’ is not a member of ‘A’
Actually, that is not valid. The C++0x FDIS says (9.2p1)
In your case, no enumerator name is introduced into the class' scope and no enumeration name is introduced either. So, no member name at all is introduced by that member-declaration.
EDIT: And actually, there's a more direct prohibition of the enumeration declaration. 7.2p2: