1. Class Time ( Operator Overloading) PLEASE READ THE MAIN FUNCTION. DO NOT CHANGE THE MAIN FUNCTION. COMPLETE THE PROGRAM TO GET THE CORRECT OUTPUT. 【Description】 Write a program to define a class Time, which contains three member variables: hour, minute and second Please realize the following functions with operator overloading: input and output time with >> and << use += and -= increase and decrease the time ,e.g.Time& operator+=(const Time&);Time& operator-=(const Time&);   【Input】 There are two line, each line is the time of a clock Input format:hour minute second。 【Output】 There are two lines. The first line is the output of time1 += time2 ; The second line is the output of time1 -= time2 ; Output format:hour:minute:second; Please read the  【Input example】 21 10 35 10 15 25 【Output example】 07:26:00 21:10:34 THE INCOMPLETE CODE. NOTE: Do not change the main function #include using namespace std; class Time {       };       int main() { Time time1,time2; cin>>time1>>time2; time1 += time2; cout<

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section: Chapter Questions
Problem 4PP
icon
Related questions
Question

1. Class Time ( Operator Overloading)

PLEASE READ THE MAIN FUNCTION.

DO NOT CHANGE THE MAIN FUNCTION.

COMPLETE THE PROGRAM TO GET THE CORRECT OUTPUT.

【Description】

Write a program to define a class Time, which contains three member variables: hour, minute and second

Please realize the following functions with operator overloading:

  • input and output time with >> and <<

  • use += and -= increase and decrease the time ,e.g.Time& operator+=(const Time&);Time& operator-=(const Time&);

     

【Input】

  • There are two line, each line is the time of a clock

  • Input format:hour minute second。

【Output】

  • There are two lines.

  • The first line is the output of time1 += time2 ;

  • The second line is the output of time1 -= time2 ;

  • Output format:hour:minute:second;

  • Please read the 

【Input example】

21 10 35 10 15 25

【Output example】

07:26:00 21:10:34

THE INCOMPLETE CODE.

NOTE: Do not change the main function

#include <iostream>
using namespace std;

class Time
{

 

 

 

};

 

 

 


int main()
{
Time time1,time2;
cin>>time1>>time2;
time1 += time2;
cout<<time1<<endl;
time1 -= time2;
cout<<time1<<endl;
return 0;

}

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning