0

I have 4 files,

HomeScene.h
HomeScene.cpp
Options.h
Options.cpp

both the *.h files have the other *.h included.
Now I am trying to inherit HomeScene.h in Options.h

class OptionScene : public cocos2d::CCLayerColor,HomeScene

the above line gives so many errors.

class OptionScene : public cocos2d::CCLayerColor

the above line has no errors

I have a static bool var; in my HomeScene.h which I am trying to use directly in my options scene.

Vinayak Garg
  • 6,518
  • 10
  • 53
  • 80

1 Answers1

2

Why do you need to include Options.h in HomeScene.h ? If OptionScene is the type derived from HomeScene, then I don't know why would you need to do that.

In case you just need to declare pointer / reference to the type declared in Options.h, you could use forward declaration.

Options.h

#include "HomeScene.h"
class OptionScene
{
    // ...
};

HomeScene.h

class OptionScene; // forward declaration

class HomeScene
{
    OptionScene* o;
};

If this is your problem, then this question will help you: When can I use a forward declaration?

Community
  • 1
  • 1
LihO
  • 41,190
  • 11
  • 99
  • 167