Makis Papapanagiotou wrote:
>
> Hello,
>
> Sorry but this is not covering my question since in your example the objects
> are not related to each other.
>
> In my case they are
>
> Test:: x( ), y(x,z), z(x,y)
>
> So the object "y" in order to be constructed needs the object "z", but "z"
> in order to be constructed needs "y" first.
> Even though they are constructed.
>
> Hence how this is done? Because it is done and it is not an error !!
It all depends on what the Cat or Dog constructor do with
the passed reference.
When the Cat constructor is called and passed the Dog object,
the Dog object isn't yet fully constructed, but the memory for
that object has already been reserved. So for the Cat object it
is safe to eg. store a pointer to the Dog object or create a reference
to it. You, the programmer, know that at exactly this memory location
eventually there will be a fully constructed Dog object, when the
whole initialization is completed.
--
Karl Heinz Buchegger