if the defaults make sense in the routines we writewe will always accept them howeverif the defaults do not make sensewe will need to implement the destructorcopy-and-move constructorsand copy-and-move assignment operators when the default does not workthe copy assignment operator can generally be implemented by creating copy using the copy constructor and then swapping it with the existing object the move assignment operator can generally be implemented by swapping member by member when the defaults do not work the most common situation in which the defaults do not work occurs when data member is pointer type and the pointer is allocated by some object member function (such as the constructoras an examplesuppose we implement the intcell by dynamically allocating an intas shown in figure for simplicitywe do not separate the interface and implementation there are now numerous problems that are exposed in figure firstthe output is three seven though logically only should be the problem is that the default copy assignment operator and copy constructor copy the pointer storedvalue thus storedvalueb storedvalueand storedvalue all point at the same int value these copies are shallowthe pointers rather than the pointees are copied secondless obvious problem is memory leak the int initially allocated by ' constructor remains allocated and needs to be reclaimed the int allocated by ' constructor is no longer referenced by any pointer variable it also needs to be reclaimedbut we no longer have pointer to it to fix these problemswe implement the big-five the result (again without separation of interface and implementationis shown in figure as we can seeonce the destructor is implementedshallow copying would lead to programming errortwo intcell objects would have storedvalue pointing at the same int object once the first intcell object' destructor was invoked to reclaim the object that its storedvalue pointer was viewingthe second intcell object would have stale storedvalue pointer this is why ++ has deprecated the prior behavior that allowed default copy operations even if destructor was written class intcell publicexplicit intcellint initialvalue storedvalue new intinitialvalue }int readconst return *storedvaluevoid writeint *storedvalue xprivateint *storedvalue}figure data member is pointerdefaults are no good