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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter11: Introduction To Classes
Section11.4: A Case Study: Constructing A Date Class
Problem 4E
icon
Related questions
Question

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

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Reference Types in Function
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