Is there a way to reuse the same enum value in separate types? I\'d like to be able to something like the following:
enum DeviceState { UNKNOWN, ACTIVE, DISABLED
For those using C++11, you may prefer to use:
enum class Foo
instead of just:
enum Foo
This provides similar syntax and benefits from as namespaces. In your case, the syntax would be:
enum class DeviceState { UNKNOWN, ACTIVE, DISABLED, NOTPRESENT, UNPLUGGED };
DeviceState deviceState = DeviceState::UNKNOWN;
Note that this is strongly typed so you will need to manually cast them to ints (or anything else).