#include <vector>
enum ListOfGameStates
{
// List of game states
};
class GameState()
{
public:
GameStates(); // Initializes protected (global) variables
virtual ListOfGameStates run() = 0;
protected:
// Heavyweigh resource managers containing all resources and other global vars
}
class GameStateManager()
{
public:
GameStateManager(); // Creates all game states
~GameStateManager(); // Deletes all game states
void run(); // Switches from one state to another state
private:
// A vector of raw pointers to game states. GameState is a base class.
std::vector<GameState*> game_states_container;
}
我想摆脱原始指针,这样我就不用担心异常和清理。是否有一个简单的解决方案(我是一个非常愚蠢的青少年)还是不值得?谢谢!