Use operator overload concept to create the operations of addition and subtraction on time.
For example, if my job took me 2 hours and 30 minutes (time1)
to complete yesterday
and it took me 3 hours and 45 minutes (time2) to complete this morning.
How do I add them together with the statement
total_time = time1 + time2 ?
How much longer time did I take it today than yesterday?
difference_time =
time2 - time1
Procedure:
1. Declare a class called Time that have two public data
members, hours and minutes.
A constructor is created. Also, there is a method called print which will
print
data members in the format as hours : minutes. For example, 9:23, 3:40, ...etc.
2. Declare an operator overload + as a general function that will add two objects of Time and return the total time as an object.
3. Declare an operator overload- as a general function that will subtract two objects of Time and return the difference time as an object.
4. Write a main function to use what you designed.