   Undefined class ?
  Heya,I started to work on new project - RPG in Console, currently Im working on Character class and got strange error:character.h(24) : error C2079: 'Character::eng' uses undefined class 'Engine'Here's my Character.h code:#ifndef CHARACTER_H#define CHARACTER_H#include "engine.h"class Engine;class Character{public:Character(Engine en, char up = 119, char down = 115, char left = 97, char right = 100);void UpdatePlayer(char c, Character ch);void Move (Character ch,int posX, int posY);//player coordinatesint mPosX;int mPosY;private:    //player movement controlschar upKey;char downKey;char leftKey;char rightKey;   //engine to handle drawingEngine eng;//error};#endif
  Since you use a plain variable to store en as Engine the compile needs to know how much space to allocate for this variable. Because of that you have to include the class header where "Engine" is defined. In this case a forward declaration alone does not help. The only thing you can do if you do not want to include the Engine Header is to make en a pointer Engine*. In this case the compile just needs to allocate enough memory to hold a pointer and it does not need to care how big the object is it points to.Edit:Just saw that you already include Engine.h. Then remove the forward declaration and make sure Engine is not defined in any namespace. If there are still problems you might have a cyclic include where Engine.h also includes Character.h. In such a case you need to show us your Engine.h file as well.   ;  Thanks Waterwalker, I changed my Engine object to pointer and all code works well, I got one logical eror, but I will handle that myself ;)   ;  Note that then there is no need to include Engine.h in Character.h. You only need to include it in character.cpp. This could clean up the code and speed up recompilation upon changing Engine.h   ;Quote:Original post by WaterwalkerNote that then there is no need to include Engine.h in Character.h. You only need to include it in character.cpp. This could clean up the code and speed up recompilation upon changing Engine.hthanks for tip :)   