When we have,
struct E { enum E_ { HELLO }; }; // 'E' is inheritable
then why do we need,
enum class E { HELLO }; // 'E' is not inheritable
IMO 2nd version doesn't offer more features than the 1st. I don't think that enum class
is introduced just to save 2 curly braces {};
! Am I missing any important aspect ?
As a minor question, is there any difference between enum class
and enum struct
other than syntax (because both have public
access specifier) ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…