I have a parent object and quite a lot of child objects (that are not fields of the parent).
The parent doesn't rely 100% on them, but it sometimes needs their support.
Sometimes a child object needs help by another child object.
Therefore the parent object needs to know all child objects, each child object needs to know (almost) every other child object but none of them needs to know the parental object.
Until that point, normal pointers do the job quite well. However, sometimes child objects die (the parent is immortal) and need to be replaced. In that case I would have to copy their new pointer target to all the other child objects which is possible but probably not very clever style.
So I thought about using references in the child objects. The parent still keeps pointers to valid child objects and each child object keeps a reference of the pointers of interest for it. So updating a pointer in the parent object would at the same time update all of the child objects.
Unfortunatly, I can't use references in objects because they need to be initialized and thats not possible in a class (or am I wrong?).
Is there any other way without the use of a pointer to a pointer (which would result in pretty messy code) ? Or maybe a trick to use references ? Should I use a different concept (ouch) ?
Any comments would help!