Class member visibility problem
-
Hi, I have a class X that instanciates many other classes that have no major relationship with it (no derivation...). However I need these classes to be able to see some members of the X instance that created them. It is not possible to use static members because they need to be specific to one instance of X. Do you see any possibility smarter than passing a reference on class X to every instanciated class ? Thanks.
-
Hi, I have a class X that instanciates many other classes that have no major relationship with it (no derivation...). However I need these classes to be able to see some members of the X instance that created them. It is not possible to use static members because they need to be specific to one instance of X. Do you see any possibility smarter than passing a reference on class X to every instanciated class ? Thanks.
Why not just create a function with which you can pass the member into.
-
Hi, I have a class X that instanciates many other classes that have no major relationship with it (no derivation...). However I need these classes to be able to see some members of the X instance that created them. It is not possible to use static members because they need to be specific to one instance of X. Do you see any possibility smarter than passing a reference on class X to every instanciated class ? Thanks.
No, I think that the main class may pass a reference to itself when it instantiates the other ones (and hopefully needed members are public).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.