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
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 "???";
}
}
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
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 "???";
}
}
0
using-enum declarations are a c++20 feature. SoloLearn currently runs C++17