dimanche 22 février 2015

How to use strongly typed enums

I'm not able to compile the following program:



#include <iostream>

using namespace std;

enum class my_enum
{
ANT,
BAT,
CAT,
DOG,
EGG,
FAN,
MAX_MEMBERS
};

int main(int argc, char * argv[])
{
my_enum i = my_enum::ANT;

for(i = my_enum::ANT; i < my_enum::MAX_MEMBERS; i++)
{
cout << "Enum value = " << i << endl;
}

return 0;
}


Could someone help me in this regard.


I see the build error as follows:


error: no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive] for(i = my_enum::ANT; i < my_enum::MAX_MEMBERS; i++)


Aucun commentaire:

Enregistrer un commentaire