• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

shallow cloning and deep cloning

 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the main difference between shallow cloning and deep cloning of objects?
 
Steve Wink
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Aaron Rhena:
What is the main difference between shallow cloning and deep cloning of objects?


Lets say you have an object which contains other objects which contain others etc. Basically, you have a complex tree of objects. A deep copy would go into each of these objects and create a copy of each of them. A shallow copy would copy the first ( outer ) object, and then copy references to the existing objects, rather than create copies of them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic