I have 3 files in my project, in the class Scene.h
I declare a public static function which I want to use in the other file of my project.
- main.cpp
#include "Scene.h"
int main(...){
Scene scene("Chapter 3", 800, 600);
...
}
- Scene.h
#include "GameObject.h"
class Scene
{
public:
Scene(...)
~Scene()
static void writeInLog(string str)
{
//write str in log.txt
}
int mainLoop(){
//a lot of thing
GameObject a;
//use this a
}
};
- GameObject.h
class GameObject
{
public:
GameObject(...)
~GameObject()
{
Scene::writeInLog("GameObject has been destroy");
}
...
};
But when I use the function in the class GameObject.h
I have 2 errors :
- error c2653 Scene.h is not a class or namespace name.
- error C3861 identifier not found.
I think it's a problem of cyclic dependency, but I can't find where. What is my mistake ?