我有以下标题和类:
game.h:
#include "GameStateManager.h"
class game
{
//bunch of lines here
}
GameStateManager.h
#include "GameState.h"
class GameStateManager
{
//bunch of lines here
}
GameState.h
class GameState
{
//bunch of lines here
}
PlayState.h
#include "GameState.h"
class PlayState : public GameState
{
//bunch of lines here
}
我需要在' game.cpp'中创建一个新的PlayState实例。我怎么能这样做?
答案 0 :(得分:1)
假设您正在使用标题保护或#pragma once
,只需:
#include "GameStateManager.h"
#include "PlayState.h"
class game
{
PlayState play_state;
//bunch of lines here
}