Copy Constructor


There are 2 good reasons for using a copy constructor instead of the constructor passing all parameters :


when you have a complex object with many attributes it is much more simpler to use the copy constructor
if you add an attribute to your class, you just change the copy constructor to take this new attribute into account instead of changing every occurrence of the other constructor

Comments

Popular Posts