Defining an enum inside a union

Hello

I want to define a union to store the various states of my game(like showing menu, playing, quitting, etc). And I made an enumeration as follows:

1
2
3
4
5
6
7
enum GameState{
   showingMenu,
   showingOptions,
   showingHighscores,
   playing,
   quitting
};


But how do I declare it in a union so that my union variable can hold only one state at a time? For example, if my union is CurrentState, it can store only one enumeration out of showingMenu, showingOptions, showingHighscores, playing, quitting.

Thanks
An enum variable can only hold one state at a time. Why do you need to put it inside a union?
@kevinkjt2000

So I can just create a class called "states" and then put my enumeration inside it and then create another class "gamStateManger" to use them?

Thanks
Last edited on
You kinda already have a class called states (enum GameState). Basically just make a variable in your gameStateManager like this:
GameState currentState;
Thanks for the help!
Topic archived. No new replies allowed.