I have some code with an enum class
in it. I only want there to exist a single instance of this enum class. I am aware of singleton classes, but is there a way to make an enum class only visible from within the current file?
Trivial example:
enum class StateInstanceOption
{
STATE_INSTANCE_A,
STATE_INSTANCE_B
}gCurrentState{StateInstanceOption::STATE_INSTANCE_A}; // global variable to hold current state "pointer" (really a flag)
Obviously the user need to be able to read/write gCurrentState
, but I don't want the user to be able to create more instances of StateInstanceOption
.
Is this possible?
To clarify, I don't want the user to be able to create another instance of StateInstanceOption
, but I do want them to be able to see gCurrentState
.