Destruction of objects

  • Thread starter Thread starter Michael Søndergaard
  • Start date Start date
M

Michael Søndergaard

I can't seem to figure this one out.

I have a list of objects containing objects like A, B, C. I also have
another object D which referer object A.
At some point in my code I need to delete the reference to object A in obj
D, so I do this D.A = null;

The question is does this only delete the reference to A or does it also
delete the object by invoking the destructor of object A. Or am I saved by
the fact, that a reference still exists to object A, because it is contained
in the list object.

Thanks
Michael Søndergaard
 
Thanks alot, that cleared some things, but then you might answer me this.

If D reference A and I set A = null, would that mean D becomes null or A
becomes null and D points to the original A, which doesn't get GC?

Michael Søndergaard
 
Michael Mayer,
Thanks for the balloon analogy. I have never heard it before, and
even though I kinda understood the gc, this makes it a bit, well,
cooler.

Scott
 
Back
Top