So, I have a variable \"state\" in a class. I want to declare it as an integer so I can save some if statements.
int state;
One way to do t
All of the code you have above works just as well if you have state declared as a State rather than an int. You can use it in a switch statement, assign it new values, do comparisons with it, etc. There really aren't any benefits to using an int here, since that's essentially "lying in the source code." Your variable isn't an integer. It doesn't make sense to multiply or divide it by a value, or to bit shift it left or right. Marking the variable as a State makes it clearer that you're really holding one of multiple values and prevents you from making some of the above mistakes. Plus, it gives the compiler a better chance to diagnose things like this:
state = 137; // Error! Can't do this assignment without a cast.
In general, use the type system to your advantage. If it's an int, make it an int. If it's an enumerated type, make it an enumerated type.