fork(6) download
  1. #include <iostream>
  2. enum class COLOR
  3. {
  4. Blue,
  5. Red,
  6. Green,
  7. Purple,
  8. First=Blue,
  9. Last=Purple
  10. };
  11.  
  12. extern const COLOR COLORS[(int)COLOR::Last+1];
  13. const COLOR COLORS[] = {COLOR::Blue, COLOR::Red, COLOR::Green, COLOR::Purple};
  14.  
  15. std::ostream& operator<<(std::ostream& o, COLOR x) {
  16. return o << std::underlying_type<COLOR>::type(x);
  17. }
  18.  
  19.  
  20. int main() {
  21. for(auto c : COLORS) {
  22. std::cout << c << '\n';
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
0
1
2
3