My game runs fine with one state defined and used. However, when I add a second state's header and cpp into my project, without even using it,
I get error C2504: base class undefined.
#ifndef GAMESTATE_H_
#define GAMESTATE_H_
#include "cGameEngine.h"
namespace DE
{
class cGameEngine; //<-tried comment out, still doesn't work
class cGameState
{
public:
virtual void Show() = 0;
virtual void Hide() = 0;
virtual void Pause() = 0;
virtual void Resume() = 0;
virtual void HandleEvents(sf::Event* theEvent) = 0;
virtual void Update() = 0;
virtual void Draw() = 0;
protected:
// cGameState constructor
cGameState(cGameEngine* game) :
m_Game(game),
m_Show(true)
{}
// Pointer to hold the game
cGameEngine* m_Game;
// bool to determine whether to show or hide the state
bool m_Show;
}; // class cGamestate
} // namespace DE
#endif //GAMESTATE_H_
I have forward declarations of all my classes in a types header file which is included into my cGameEngine class header. Could this have anything to do with it?
Here is where the compiler is saying the error is
#ifndef SPLASH_SCREEN_H
#define SPLASH_SCREEN_H
#include "cGameState.h"
namespace DE
{
class SplashState : public cGameState
{
public:
SplashState(cGameEngine* game);
~SplashState();
void Show();
void Hide();
void Pause();
void Resume();
void HandleEvents(sf::Event* theEvent);
void Update();
void Draw();
/* static SplashState* Instance()
{
return &m_SplashState;
}
*/
protected:
// SplashState(){}
private:
// static SplashState m_SplashState;
sf::Sprite* m_Player;
sf::Sprite* m_BackGround;
cp::cpButton m_StartButton;
}; // class SplashState
} // namespace DE
#endif // SPLASH_SCREEN_H