When we have,
struct E { enum E_ { HELLO }; }; // \'E\' is inheritable
then why do we need,
enum class E { HELLO }; // \'E
In the first case, the type of HELLO
is not E
, whereas in the second case, the type of HELLO
is E
.
For a good demonstration of why this is important, see Howard Hinnant's answer to "“enum class” emulation or solid alternative for MSVC 10.0."
enum class
and enum struct
are "semantically equivalent" (i.e., the same), per C++0x FDIS §7.2/2.