If class3 actually needs to access manager1, then pass a bloody reference to manager1 into class3's constructor. More likely, class3 needs to access some subset of the functionality in manager1, in which case, factor that common functionality out, and stop naming things catch-all phrases like 'manager', so that you stop violating the single responsibility principle...
I'm totally agree with you, I don't want to have statics everywhere (only I have 5),
this is what happend:
Initially i had a core object(which was static = m_Core pointer) and their class private members (renderer, objectmanager, Scene,...).
the situation: I needed to call some manager inside SceneInit function from scene.cpp (basically the same example as my previous post).
Inside InitScene() I created the triangle. Once the gameobject is created is added to the objmanager list (a vector) (every gameobject had a reference to this objmanager).
Scene.cpp
void SceneManager::SceneInit()
{
GameObject* obj1;
//set the gameobject
m_Core->getObjmanager()->AddGameObject(obj1);
//added to objectmanager vector
//a lot of code, set shader, and stuff
}
The application simply didn't work (application-->Show a green triangle), it showed a colored background (without triangle).
I assumed that the object did not created, maybe it did, so I decided to pass a manager (objectmanager pointer) to the sceneInit function and check if the manager contain the object:
Scene Init changed
void SceneManager::SceneInit(objmanager* m_objmanager)
{
GameObject* obj1;
//set the gameobject
m_objmanager->AddGameObject(obj1);
//added to objectmanager vector
//a lot of code, set shader, and stuff
}
It worked, So i decided to pass every manager as arguments to the function that needed them (and to be clear, this is what I want)----->here the problems appeared. I had troubles to render, because i was passing "renderer" to a component of a gameobject that was on a vector of a manager, and that renderer to the meshrenderer, to the material, to the shader ...
Two ways 1) review every line of code (which i did) and try to figure out what was the problem (which i didn't) .....and 2) try another method...
then I discover the singletons ---> the result: everything works!, even now, So, are they pureee evill? ...
What is the difference in the above code? i mean, why it worked when passing the pointer?