CS202 Copy Constructors
5
Copy Constructors
•To resolve the pass by value and the initialization issues, we must write a copy constructor whenever dynamic member is allocated on an object-by-object basis.
•They have the form:
•
•class_name(const class_name &class_object);
•
•Notice the name of the “function” is the same name as the class, and has no return type
•The argument’s data type is that of the class, passed as a constant reference (think about what would happen if this was passed by value?!)