Homework 12


Due : 9.30am, 26 July

Answer the following questions on Copy Constructors:

  1. What is a copy constructor ?
  2. Describe two instances in which we NEED a copy constructor (ie when not having it could result in errors) ?
  3. How many parameters does a copy constructor take ?
  4. What are the types of the parameters ?
  5. What is the return type of a copy constructor ?

Solution

  1. A copy constructor is a function called automatically by the compiler to create a copy of an object.
  2. 1
  3. A reference to the same type as the object itself.
  4. There is no return type since it is a constructor.

Last updated : 26 July 2000 12.41pm