You are here:

C++/deep and shallow copy

Advertisement


Question
in simple terms, the difference(s), in C++, between a deep copy and a shallow copy.  When is a deep copy necessary?  

Answer
ken, Thank you for your question.

I'm not sure that these are C++ concepts.

A shallow copy generally means copying bits from one memory block to another.

A deep copy generally means recursively copying variables in a nested structure, or objects in a nested object.

David Spector

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


David Spector

Expertise

Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.

Experience

I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Publications
Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

Education/Credentials
ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2016 About.com. All rights reserved.