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

Why is swift so fast?

0 Answers  


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

0 Answers  


What should main() return in c and c++?

0 Answers  


What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor

0 Answers  


pls help.. paper bills.. 1000, 500, 100, 50, 20, 10, 5, 1.. create a program that will count all the paper bills in the number being input.. example: enter a number: 3886 there is/are: 3 ->1000 1 ->500 3 ->100 1 ->50 1 ->20 1 ->10 1 ->5 1 ->1 example2: enter a number: 728 there is/are: 0 ->1000 1 ->500 2 ->100 0 ->50 1 ->20 0 ->10 1 ->5 3 ->1

4 Answers  






What is the difference between a baller and a reference in C++?

0 Answers  


i want the NIC programmer-B model papaer pattren, iwant the all model papers?

15 Answers   NIC,


Comment on assignment operator in c++.

0 Answers  


Why is polymorphism useful?

0 Answers  


Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.

0 Answers   TCS,


What is set in c++?

0 Answers  


What is the difference in size of this two clasees? Class A { int a; char c; float f; } Class B { float f; char c; int a; }

4 Answers  


Categories