We have classes A, B and C, all of which need access to a static variable staticVariable in class D.
Moreover, class A needs to have an instance of classes B and C like this:
    class A{
    public:
    B instanceB;
    C instanceC;
    };
Class D hold the static variable of object type T:
    class D{
    public:
    D() {
    staticVariable.init();
    };
    static T staticVariable;
    };
In the example classes B and C can be empty placeholder classes:
    class B{
    };
    class C{
    };
The main function creates an instance of A:
    int main(){
    A a;
    /*...*/
    }
Again, classes A, B and C need access to staticVariable. I've tried multiple approaches including inheritance and friend functions, however I always get dependency issues or linker errors I don't quite understand:
    Error   LNK2001 unresolved external symbol "public: static class T 
    D::staticVariable" (?window@D@@2VT@sf@@A)   SortingAlgorithms    
    C:\Users\Dusan\source\repos\SortingAlgorithms\SortingAlgorithms\B.obj       
is being reported in .obj files of classes A, B and C.
I'm not sure if I need an instance of D in main.
How do I implement this error-free?
And how do you do it for static objects that call a function for initialization?
I meant if the function is of the same class as the object you're trying to initialize, and is non-static, I can't seem to be able to call staticVariable.init();
 
    