What is difference between shallow copy and deep copy? Which is default?
Answer Posted / hrpynux@gmail.com
Default version of clone method creates the shallow copy of an object. To create the deep copy of an object, you have to override clone method. Shallow copy is preferred if an object has only primitive fields. Deep copy is preferred if an object has references to other objects as fields.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain rtti.
What are multiple inheritances (virtual inheritance)?
How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?
Which one is better- macro or function?
What are the advantages of c++ over c?
What is the difference between strcpy() and strncpy()?
How does atoi function work?
Explain object slicing in c++?
What is difference between rand () and srand ()?
Define a constructor - what it is and how it might be called (2 methods)?
What is the use of ::(scope resolution operator)?
Explain the uses of static class data?
When does a 'this' pointer get created?
Explain how overloading takes place in c++?
What is == in programming?