I'm making a c++ OpenGL project and I'm having trouble with static variables.
I have a header "Scene.h" like so:
#pragma once
#include "A.h"
class Scene
{
//class body
};
static Scene* active = new Scene();
And my A.h file looks like this:
#pragma once
#include "Scene.h"
class A
{
active->SomeMethod(); //Here I get error C2065: undeclared identifier
};
In my source file I have included only my Scene.h, since it includes A.h already, and I have no problem there.
I have also tried to use a static Scene object like so:
class Scene
{
static Scene* active;
};
And then to access it like so:
Scene::active->DoSomething();
But then I get error C2653: Scene is not a class or namespace name. I read somewhere that to do this I need precompiled headers, and that is no option for me.
What is the correct way to have a static pointer in this case?