0

I have just seen similar question but that doesn't solve my problem, because I'm struggling with inheritance. That's how my simplified code looks:

Game.h

#include "Ghost.h"

class Game
{
   Ghost * myGhost;
};

Ghost.h

#include "MovableItem.h"

class Ghost : public MovableItem
{
   Ghost(Game * parentGame) : MovableItem(parentGame)
   {
   }
};

MovableItem.h

class MovableItem
{
   MovableItem(Game * parentGame);
};

When I'm trying to use forward declaration of class Game, I get 'invalid use of incomplete type class Game' compilation error and without that declaration I get 'Game does not name a type'. How can I solve that problem? Thanks for advance.

Kamil Turek
  • 77
  • 1
  • 6
  • You likely forgot to include the header containing the forward declared type in your implementation files. – François Andrieux Apr 04 '18 at 18:45
  • @FrançoisAndrieux Yeah, I was making forward declaration in header file and then I should include in cpp header to class that I want to refer. Problem solved. Thanks. – Kamil Turek Apr 05 '18 at 10:12

0 Answers0