CS Electrical And Electronics
@cselectricalandelectronics

Why should we provide our own copy constructor when default copy constructor is already provided by the compiler?

All QuestionsCategory: Cpp LanguageWhy should we provide our own copy constructor when default copy constructor is already provided by the compiler?
CS Electrical And Electronics Staff asked 3 years ago

I need short information.

1 Answers
CS Electrical And Electronics Staff answered 3 years ago

Normally, there is no need to write our own copy constructor when default copy constructor is already provided by the compiler itself. When the default copy constructor is called, exact copy of the original object is available due to bitwise copying. In such situations both the objects will share the same set of memory locations i.e., both of them point to the same place.Â