I have two classes. One main Game class and an Entity class that needs to point to the Game class so it can call its various functions
Entity.h
class Game;
class Entity
{
public:
Entity(Game *game);
~Entity(void);
void Draw(float dt);
void Update(float dt);
protected:
Game *m_game; // Missing type specifier error C4430
};
Entity.cpp
#include "Entity.h"
Entity::Entity(Game *game)
: m_game(game) // Initialise members
{
}
Entity::~Entity(void)
{
}
void Entity::Draw(float dt)
{
}
void Entity::Update(float dt)
{
m_game->DoSomething(); // Missing type specifier error C4430
}
I've forward declared my Game class but I can't use it anywhere in the Entity class as I always get
Missing type specifier error C4430
when trying to access it through intellisense (CTRL + J).
My Game header file doesn't appear to cause any circular dependencies.
Game.h
#include <list>
using namespace std;
class Entity;
class Game
{
public:
list<Entity*> m_entities;
Game(void);
~Game(void);
void init();
void draw(float dt);
void loadContent();
void update(float dt);
}
What's going on?