-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtime01.cpp
More file actions
41 lines (39 loc) · 959 Bytes
/
time01.cpp
File metadata and controls
41 lines (39 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//time01.cpp ---- The following code creates three objects of class Time and adds them using operator overloading
#include <iostream>
#include "time00.h"
using namespace std;
int main()
{
int h = 0, m = 0, s = 0;
cout<<"Please enter the time as hh:mm:ss."<<endl;
cout<<"Hours:"<<endl;
cin>>h;
cout<<"Minutes:"<<endl;
cin>>m;
cout<<"Seconds:"<<endl;
cin>>s;
Time t1(h, m, s);
t1.display();
cout<<"First time object created successfully. Please enter the second set of details."<<endl;
cout<<"Hours:"<<endl;
cin>>h;
cout<<"Minutes:"<<endl;
cin>>m;
cout<<"Seconds:"<<endl;
cin>>s;
Time t2(h, m, s);
t2.display();
cout<<"Second time object created successfully. Please enter the third and final set of details."<<endl;
cout<<"Hours:"<<endl;
cin>>h;
cout<<"Minutes:"<<endl;
cin>>m;
cout<<"Seconds:"<<endl;
cin>>s;
Time t3(h, m, s);
t3.display();
Time result = t1 + t2 + t3;
cout<<"Total time:"<<endl;
result.display();
return 0;
}