#include #include using namespace std; enum class ColorT: char {RED, GREEN, BLUE, UNKNOWN}; const ColorT FIRST_COLOR = static_cast(0); ColorT NextColorT(ColorT c); string ColorTToString(ColorT c); ColorT StringToColorT(string s); // need a dummy int param to show it is i++ and not ++i ColorT operator ++(ColorT & c, int ) { return c = NextColorT(c); } ostream & operator << (ostream & s , const ColorT & c) { s << ColorTToString(c); return s; } enum struct MoodsT { HAPPY, SAD, BLUE, UNKNOWN}; int main() { MoodsT myMood{MoodsT::BLUE}; if (myMood == MoodsT::BLUE) { cout << "I'm sorry you are unhappy" << endl; } for(ColorT i = FIRST_COLOR; i != ColorT::UNKNOWN; i = NextColorT(i)) { cout << ColorTToString(i) << endl; } for (auto i = FIRST_COLOR; i != ColorT::UNKNOWN; i++) { cout << i << endl; } return 0; } string ColorTToString(ColorT c){ switch(c) { case ColorT:: RED: return "Red"; case ColorT:: GREEN: return "Green"; case ColorT:: BLUE: return "Blue"; case ColorT:: UNKNOWN: default: return "Unknown"; } return "Unknown"; } ColorT NextColorT(ColorT c){ if (c != ColorT::UNKNOWN) { return static_cast(static_cast(c) +1); } return ColorT::UNKNOWN; }