(Just in case that there were no misunderstandings: this is not about inheritance, but about the creation of objects)
With the usual hierarchy of parent-child classes, the parent knows everything about the child and can fully interact with it. But what to do when children need to know about each other and interact with each other?
How to implement it correctly?
I implement it as follows - for this I use a separate class, say GlobalData , I pass it a reference to the used object, let it be objA . And in another objB object, objB get access to the desired method of the first object.
GlobalData.objA.needMethod(); At the same time I have GlobalData - singleton .
What is the right thing to do in this case? What templates are used for this? Or do I still do everything right?
