ILE C/C++ Programmer's Guide


Using Shallow Copy instead of Deep Copy

Avoid performing a deep copy if a shallow copy is all you require. For an object that contains pointers to other objects, a shallow copy copies only the pointers and not the objects to which they point. The result is two objects that point to the same contained object. A deep copy copies the pointers and the objects they point to, as well as any pointers or objects contained within that object, and so on.

Note:
If a program points to an object more than once, you must use deep copy. Objects that use shallow copy can destroy objects pointed to more than once.


[ Top of Page | Previous Page | Next Page | Table of Contents ]