A class named clock has two instance variables: hours (type int) and isticking (type boolean). write a constructor that takes a reference to an existing clock object as a parameter and copies that object's instance variables to the object being created.your task: write a clock constructor that makes this possible. just write this constructor -- don't write the whole class or any code outside of the class!

Respuesta :

tonb
You can use the initializer list for that; no code needed:

Clock(const Clock& rClock) : hours(rClock.hours), isTicking(rClock.isTicking)

   // no code needed
}

In fact, the compiler will provide this copy constructor by default, you don't even have to write this constructor!