Directory

Encyclopedia

NodeWorks
                              ENCYCLOPEDIA

Link Checker

Home
Encyclopedia : O : OB : OBJ :

Object copy

 

Object copy

In computing, a deep copy is copy that contains the complete encapsulated data of the original object, allowing it to be used independently of the original object. In contrast, a shallow copy is a copy that may be associated to data shared by the original and the copy.

For example, if a C++ class contains a pointer to a null-terminated string, the deep copy would also copy the string, while the shallow copy would create an object where the pointer points to same string, and changes to it affect both objects.

In computing, the result of shallow copying one object to another variable is two variables pointing to the same physical object in memory.

Thus changing the object pointed to by one of the variables will also cause the contents of the other variable to change (since the same object in memory is being altered).

Shallow copies are common when reference counting objects. The technique is by default when copying objects in Java.


NodeWorks boosts web surfing!
Page Returned in 0.025 seconds - HTML Compressed 69.2%

This article is from Wikipedia. All text is available
under the terms of the GNU Free Documentation License.
 GNU Free Documentation License
© 2008 Chamas Enterprises Inc.