Circular Include and dependency

i've this cenary:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//Command.h

#include "Game.h"
class Command{
   ....
   void findCommand(string command,Game &g);
}


//Game.h
class Command;
class Game{
   Command* com;
public:
   ....
}


The problem is when use in

1
2
//Game.cpp
this->com->findCommand(str,*this);


Error: pointer to incomplete class type is not allowed , why??
Last edited on
Because you try to use the object before the class has been defined. The solution is to include Command.h in Game.cpp.
Oo! It works!! Thanks Peter87!
Topic archived. No new replies allowed.