2 ms·
Why is an enum a class? What does that even mean semantically? Why can't an enum simply be ... an enum? Even if under the covers an enum is/was implemented as
by zelphirkalt 2y ago
Why is an enum a class? What does that even mean semantically? Why can't an enum simply be ... an enum?
Even if under the covers an enum is/was implemented as a special class, why would the language syntax leak this implementation detail to the programmer?
Perhaps it would be cleaner to make enum its own concept, rather than trying to shoehorn it into classes. It is a fundamentally different thing than a class after all. Is there a reason, why this is not done?
- tialaramex 2y agoBecause C++ has no way to compatibly adjust its syntax, it's important to them to reuse keywords where possible. So enum and class were two existing keywords whereas scoped would be a new keyword. There's also a sentiment among C++ proponents that classes (a user defined product type with implementation inheritance) are all you really need anyway.