Sunday, November 25, 2012

Object copy


In short, it depends on what points to what. In a shallow copy, object B points to object A's location in memory. In deep copy, all things in object A's memory location get copied to object B's memory location.
This wiki article has a great diagram.

Shallow Copy:
Before Copy Shallow Copying Shallow Done
Deep Copy:
Before Copy Deep Copying Deep Done


No comments:

Post a Comment