>> Well, it would have to be a constant expression, which a get method wouldn't do.
The problem is in the switch, not the case. This works fine:
Code:
class state {
public:
enum {
Undefined = 0,
Arkansas = 1,
Alaska,
California
};
protected:
int value;
public:
state() : value(Undefined) { }
state(int val) : value(val) { }
state(state &o) : value(o.value) { }
int get_state() const { return value; }
state operator=(int val) {
value = val;
return *this;
}
};
int main()
{
state state1(state::California);
switch (state1.get_state())
{
case state::Alaska:
case state::Arkansas:
case state::California:
default:
break;
}
}