Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
An enum class is a C++11 type-safe enumeration. Prefer class enums over plain enums to minimize surprise [1].
An enum class is a conversion-safe enum:
enum class Color { red , orange }; |
Screen output:
cannot convert 'Color' to 'Fruit' in initialization |
Technical note: the code shown is compiled successfully using the G++ 4.4.5 compiler, which is supplied with the Qt Creator 2.0.0 IDE.
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.