Search⌘ K

Scoped Enumerations

Explore the differences between classical and scoped enumerations in C++. Understand how scoped enumerations improve type safety by restricting enumerator scope and preventing implicit conversions to int. Learn the syntax and usage of strongly-typed enums to write safer and clearer C++ code.

Enumerations allow us to define a custom data-types containing integer constants. These integer constants are called enumerators. Sadly, classical enums have a few drawbacks.

Drawbacks of enumerations in classical C++ #

Three of the biggest drawbacks of classical enumerations are listed below:

  1. Enumerators implicitly convert to ...