Ask Question

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!

+2
Answers (1)
  1. 30 May, 14:09
    0
    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!
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A class named clock has two instance variables: hours (type int) and isticking (type boolean). write a constructor that takes a reference ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers