What are the advantages of scoped enums over unscoped enums?
Show answer and explanation
A scoped enum (enum class) keeps enumerators in its scope, avoids implicit conversion to integers, and allows an explicit underlying type. These properties reduce name collisions and accidental arithmetic.
A scoped enum (enum class) keeps enumerators in its scope, avoids implicit conversion to integers, and allows an explicit underlying type. These properties reduce name collisions and accidental arithmetic.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.