Question: Language is C++ 1 v #include 1. Time 2 3 using namespace std; 4 Create a class called Time that has separate int member data

Language is C++Language is C++ 1 v #include 1. Time 2 3 using namespace

1 v #include 1. Time 2 3 using namespace std; 4 Create a class called Time that has separate int member data for hours, minutes, and seconds. One constructor should initialize this data to 0, and another should initialize it to passed values. Another member function (show) should display it, in 23:59:59 format. There should be overloaded + operator that adds the time of the object passed, and returns a Time object. A main() program is given, where two initialized time objects are created. Then it adds the two initialized objects together, leaving the result in the third time object. Finally it displays the value of all the time objects. 11 5 6 v int main() { 7 /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 8 int hh, mm, ss; 9 cin>>hh>>mm>>ss; 10 Time ti(hh, mm, ss); //ti(hh, mm, ss) cin>>hh>>mm>>ss; 12 Time t2 (hh, mm, ss); 13 Time t3; 14 t3=t1+t2; //adding two times should produce a valid time, overflowed hours/minutes/seconds should be adjusted. 15 // e.g. adding 18:10:20 with 10:20:30 results in 4:30:50 16 17 ti.show(); 18 t2.show(); 19 t3.show(); 20 return 0; 21 If any number exceeds its limit, it should be carried forward. For example, if the seconds are more than 59, they should carry forward to minutes. If the hours are more than 23, they can be truncated, as it will carry forward to next day

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!