CS202 Copy Constructors
8
Copy Constructors
•Copy constructors are also used whenever passing an object of a class by value: (get_name returns a ptr to a char for the current object)
•
•int main() {
•  name smith("Sue Smith"); //constructor with arg used
•
•  //call function by value & display from object returned
•  cout <<function(smith).get_name() <<endl;
•  return (0);
•}
•
•name function(name obj) {
•  cout <<obj.get_name() <<endl;
•  return (obj);
•}
•