I have a class that has a static pointer to another class, which is a singleton. The problem that I seem to be getting though is that I cannot set the pointer from within the constructor of said class. Here is my current code:
class B;
class A
{
public:
A();
~A();
};
class B
{
public:
B();
~B();
static A* a;
};
A::A() {
A* B::a = this;
}
Now, the problem that I seem to be getting is that I cannot define B::a in the "current scope". In addition, the "this" pointer can only be used in a "nonstatic member function".
I think the problem has to do with defining the static class variable within another class function, but I am not sure.