+ 1

When no copy constructor is defined, the compiler supplies its own copy comstructor.

Copy constructor query

12th Jun 2017, 6:58 PM
Akshit Agarwal
Akshit Agarwal - avatar
5 Réponses
12th Jun 2017, 7:14 PM
Burey
Burey - avatar
+ 9
that is correct but take into consideration that the copy constructor only performs shallow copy of variables, meaning that if you use pointers or references to another objects, you will get 2 objects which points to the same addresses. and ince one object is deleted, if the references are properly cleaned, the other object will point to garbage values and you don't want that tl/dr: implement your own copy constructors
12th Jun 2017, 7:06 PM
Burey
Burey - avatar
+ 5
yes it is useful as it allows you to do certain things which would require a constr but better define your own
12th Jun 2017, 7:09 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 1
Thanks
12th Jun 2017, 7:18 PM
Akshit Agarwal
Akshit Agarwal - avatar
0
Can u please give a code related to it so that i can understand it clearly sir..
12th Jun 2017, 7:08 PM
Akshit Agarwal
Akshit Agarwal - avatar