Why is a copy constructor important C++?

Main point: The copy constructor is necessary when you have a dynamic memory allocation (heap) in an object constructor, you need to do a copy of allocated memory to the new assigned objects also. In that way you could be able to (Obj1 = Obj2 / Obj1(Obj2) ) and guarantee the dynamic memory will be copied also.

Sizin İçin Seçtik  Why are default constructors used?

Leave a Reply

Your email address will not be published. Required fields are marked *