Question: Language: C++ Please follow the given instructions, Thank you. Create a class called Time that has separate integer member data for hours, minutes, and seconds.
Language: C++
Please follow the given instructions, Thank you.
Create a class called Time that has separate integer member data for hours, minutes, and seconds. Provide the following member functions for this class:
i. A no-argument constructor to initialize hour, minutes, and seconds to zero.
ii. A 3-argument constructor to initialize the members to values sent from the calling function at the time of creation of an object. Make sure that valid values are provided for all the data members. In case of an invalid value, set the variable to zero.
iii. A member function show to display time in 11:59:59 format.
iv. A function AddTime for addition of two Time objects. Each time unit of one object must add into the corresponding time unit of the other object. Keep in view the fact that minutes and seconds of resultant should not exceed the maximum limit (60). If any of them do exceed, subtract 60 from the corresponding unit and add a 1 to the next higher unit.
A main() program should create two initialized Time objects and one that isnt initialized. Then it should add the two initialized values together, leaving the result in the third Time variable. Finally it should display the value of this third variable.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
