hi guys just wondering if it's possible to overload operators for enums?
the code actually compiles fine so it lets me overload the ++ operator BUT in main when I try to use it m++ it gives me an error no operator++(int) declared for postfix '++'
#include <iostream>
usingnamespace std;
enum Month{
JAN = 1,
FEB,
MARCH,
APRIL,
MAY,
JUNE,
JULY,
AUGUST,
SEPTEMBER,
OCTOBER,
NOVEMBER,
DECEMBER
};
Month operator++(Month& m){
if(m == DECEMBER){
m = JAN;
return m;
}else{
m = Month(m+1);
return m;
}
}
int main()
{
Month m = FEB;
cout << m << endl;
m++;
}