KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Yesterday I asked a question about copying objects in C#, and most answers focussed on the difference between deep copy and shallow copy , and the fact that it should be made clear which of both copy variants a given copy constructor (or operator, or function) implements. I find this odd. I wrote a lot of software in C++, a language that heavily relies on copying, and I never ever needed multiple copy variants. The only kind of copy operation I ever used is the one I call " deep enough copy ". It does the following: In case the object has ownership over the member variable (cf. composition ), it is copied recursively. In case the object has no ownership over the member variable (cf. aggregation ), only the link is copied. Now, my question is threefold: 1) Does an object ever need more than one copy variant? 2) Does a copy function need to make clear which copy variant it implements? 3) As an aside, is there a better term for what I call "deep enough copy"? I asked a related question about the definition of the term "deep copy" .
Tags (comma-separated)
Save Edits
Cancel