|
|
|
|
|
|
Is incrementing an enum necessarily a good idea? A slight change to the ordering of the enum elements could change program behaviour. I think the problem with your operator is that it is defined incorrectly. ++ is an unary operator, but you have given it two parameters (what is the int for?). In fact, I think this operator must be a member function, which I don't think is possible for an enum. Also ++ is supposed to change the original value, whereas you have just returned and incremented value, leaving the original value unchanged. You would need a reference parameter to do this correctly. EDIT: But you could just define an increment function to increment it, bearing in mind the various points I have made above. |
Don't do math on an enum. How about: const int blah = 1; const int blah2 = 2; const int blah3 = 3; -> EDIT: I successfully made a nonmember increment operator for a class, but the same code failed for an enum. As abellia said, math on an enum is not a great idea :P |
|
|
|
|
Error 1 error C2440: 'return' : cannot convert from 'ControlType' to 'ControlType &' 2 IntelliSense: initial value of reference to non-const must be an lvalue |
|
|
|
|
|
|