I have the main classA, it creates instances of class B, this in turn creates instances of class C,
Imagine my class C ask for a value that I have to pass up to 'grandfather' classA.
How can I do this ?
Thanks
You could give every instance of B knowledge of (e.g. a pointer) to the A that made it, and every C a pointer to the B that made it, and the classes could thus pass data back and forth to each other.
So if I want to have a global variable for the whole project I have to pass it to the clasess I want to have access to this global isn't it ?
So at every constructor I'd have to pass every 'global variable', in example,
my_instance_of_classn = new MyclassN (..., globalvar1, globalvar2, etc )
Or maybe can be better to have an struct for my global structure , isn`t it ?
Thanks
Another option is to create a "singleton" object. That is, throughout your whole program, there is only one such object instantiated. Any section of code that tries to create one actually gets the same one that everyone else is using.