I don't understand why I get this compiler errors:
error C2027: use of undefined type 'GameState' note: see declaration of 'GameState' error C2338: can't delete an incomplete type warning C4150: deletion of pointer to incomplete type 'GameState'; no destructor called
This is the relevant code:
#pragma once
#include <SFML\Graphics.hpp>
#include "SpawnManager.h"
#include "Resource.h"
#include <stack>
#include <memory>
class GameState;
class Controller
{
public:
Controller();
void run();
void setPlayerScore(unsigned score);
sf::RenderWindow& getWindow() { return m_window; }
void addState(const States& state);
void changeState(const States& state);
GameState* getState() const;
void popState();
void add_state(const States& type, Controller * cont);
~Controller() {}
private:
SpawnManager<States, GameState> m_sFactory;
sf::RenderWindow m_window;
ScoreRecord m_playerScore;
std::stack<std::unique_ptr<GameState>> m_screens;
};
#pragma once
#include <SFML\Graphics.hpp>
#include <memory>
#include "Controller.h"
//State design pattern
class GameState
{
public:
explicit GameState(Controller* state_holder);
GameState(const GameState&) = delete;
GameState(GameState&&) = delete;
GameState& operator=(const GameState&) = delete;
GameState& operator=(GameState&&) = delete;
virtual ~GameState() = default;
virtual void displayState() = 0;
virtual void updateStage() = 0;
virtual void handleEvent(sf::Event& event) = 0;
protected:
std::unique_ptr<Controller> m_state;
};
Any ideas how to fix this?