I have an enum but I intend to have the enum itself as an array that I can walk through as a list:
#include <iostream>
using namespace std;
typedef enum p_states {
    ALL,
    SEMI,
    COMBO1,
}states;
states s;
int main()
{
    s = ALL;
    cout<<s[0]<<endl;
    cout<<s[1]<<endl;
    cout<<s[2]<<endl;
}
Which results in the errors:
enum_states.cpp: In function ‘int main()’:
enum_states.cpp:12:11: error: invalid types ‘states {aka p_states}[int]’ for array subscript
  cout<<s[0]<<endl;
           ^
enum_states.cpp:13:11: error: invalid types ‘states {aka p_states}[int]’ for array subscript
  cout<<s[1]<<endl;
           ^
enum_states.cpp:14:11: error: invalid types ‘states {aka p_states}[int]’ for array subscript
  cout<<s[2]<<endl;
           ^
I can only think of having an array states.
s[3] = {ALL,SEMI,COMBO1};
Is there a better way of defining this only once and have it as an enum?
 
     
     
     
    