0

Enums

I read that using enum class, compiler can't use an enum class in all scopes however using the statement "using enum Enum_Name". You can use ur enumerators from Enum_Name in that scope... So why my code doesn't work? https://code.sololearn.com/ci0I90tI5x7q/?ref=app

26th Jul 2022, 2:38 AM
Marco CĂĄrdenas
Marco CĂĄrdenas - avatar
4 Answers
0
Fix it and it will work: enum Color { black, red, blue, }; constexpr std::string_view getColor(Color color) { switch (color) { case black: return "black"; case red: return "red"; case blue: return "blue"; default: return "???"; } }
26th Jul 2022, 3:12 AM
Solo
Solo - avatar
0
Solo thanks but I don't want to use unscope enumeration... I want to use scope enumeration and want to know why my statement "using enum Color" doesn't work in my case
26th Jul 2022, 3:16 AM
Marco CĂĄrdenas
Marco CĂĄrdenas - avatar
0
enum class Color { black, red, blue, }; constexpr std::string_view getColor(Color color) { switch (color) { case Color::black: return "black"; case Color::red: return "red"; case Color::blue: return "blue"; default: return "???"; } }
26th Jul 2022, 4:25 AM
Solo
Solo - avatar
0
using-enum declarations are a c++20 feature. SoloLearn currently runs C++17
26th Jul 2022, 6:15 PM
XXX
XXX - avatar