Hello
Someone posted the following code on this forum a while ago:
Code:
class state {
public:
enum {
Undefined = 0,
Arkansas = 1,
Alaska,
California
};
protected:
int value;
public:
state() : value(Undefined) { }
state(int val) : value(val) { }
state(const state &o) : value(o.value) { }
state operator=(int val) {
value = val;
}
};
This gives 2 errors: first error is because of const state (3rd contructor) and the second error is that operator= must return a value..
I would like to be able to do the following with this class:
Code:
state s1, s2;
s1 = state::Alaska;
s2 = state::California;
if (s1 == s2) ..
How should I overload operator= properly in this case?
Or if I want to do s1 = s2 = s3?
Thanks a lot for help!