I am writing a simple board game where the players place pieces on a board. (theres more to it than that, but you get the idea)
I needed a system where, on one screen the player can view the board and select tiles, and on the other they can select from a menu the type of tile they want to place.
For this I needed two 'states', each one handling input and output differently. So I created these as classes, both inheriting from the 'state' class. The thing I have had difficulty with is switching between these classes, since they cant see each other, and how the current state pointer switches from one state to the next will depend on the original state. What I have done is given the state class a 'states' static vector, which stores pointers to all the states that have been created, and a non-static 'keys' vector which stores the input needed to access that state from the this state (so the two vectors sort of line-up).
Anyway this seemed kind of messy and there is probably a reason why you shouldn't do this and i'm probably doing everything wrong anyway. So I'm posting this on here to ask for some feedback before I make it even worse.
Here is the program. (its not actually a board game here. I've reduced it to just the basic state system)