#INFO_CPP What is the difference between shallow and deep - TopicsExpress



          

#INFO_CPP What is the difference between shallow and deep copy? Shallow copy involves bit wise copy of the contents of one object into another object of the same type. A copy constructor and assignment operator provided by the compiler by default does shallow copy. Shallow copies create a problem when there are fields of pointer or reference type. In this case, the addresses are directly copied to another object and thus two different objects have fields pointing to the same objects. When one object is destroyed, the pointers/references in the other object become dangling pointers/references, which is dangerous. Deep copy involves using the contents of one object to create an other instance of the same class. In a deep copy, the two objects may contain the same information but the target object will have its own buffers and resources. The destruction of one object will not affect the other object. Typically, we provide our own copy constructor and assignment operator implementations for doing deep copy of objects
Posted on: Thu, 18 Jul 2013 14:20:31 +0000

Trending Topics



div>
Impôt sur la mort : la France crève le plafond Publié le :
Rich is the funniest person I know - he can make me laugh when I
Truyện Hay: MẸ ĐỘC THÂN 18 TUỔI Trong tư thế thân
payday loans in georgia with no checking account
YG-1 L7 Series Vanadium Alloy HSS Spiral Pointed Tap, Uncoated
LAGOS — A 22-year-old un-dergraduate of Caleb University, Lagos,

Recently Viewed Topics




© 2015