What is difference between shallow copy and deep copy? Which is default?



What is difference between shallow copy and deep copy? Which is default?..

Answer / 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

More C++ General Interview Questions

What is the difference between method overloading and method overriding in c++?

0 Answers  


Does c++ have foreach?

0 Answers  


What is scope resolution operator in c++ with example?

0 Answers  


what is the use of templates?

3 Answers  


How does com provide language transparency?

0 Answers  






What is a catch statement?

0 Answers  


What is an operator function? Describe the function of an operator function?

0 Answers   Fidelity,


In int main(int argc, char *argv[]) what is argv[0] a) The first argument passed into the program b) The program name c) You can't define main like that

0 Answers  


what is static function

2 Answers   Patni,


What is setbase c++?

0 Answers  


Can user-defined object be declared as static data member of another class?

0 Answers  


Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others ].

1 Answers  


Categories