-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime.cpp
More file actions
57 lines (53 loc) · 1.05 KB
/
time.cpp
File metadata and controls
57 lines (53 loc) · 1.05 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>// adding the iostream library
#include <string> // adding the time library
#include "time.h" // adding the time header
using namespace std;
time::time() // default constructor
{
hour = 0;
mins = 0;
}
time::time(int hh, int mm) // non - default constructor
{
hour = hh;
mins = mm;
}
void time::setHours(int hh) // method set hour
{
hour = hh;
}
void time::setMins(int mm) // method set mins
{
mins = mm;
}
void time::setTime(int hh, int mm) //method set time
{
hour = hh;
mins = mm;
}
int time::getHours()const // method to get hour
{
return hour;
}
int time::getMins()const // method to get mins
{
return mins;
}
int time::getTime()const
{
return (hour,mins);
}
void time::print()const // method to print
{
cout<<hour<<":"<<mins;
}
istream& operator >>(istream& inputObj, time& t) // input operator
{
inputObj >>t.hour>>t.mins;
return inputObj;
}
ostream& operator <<(ostream& outputObj, const time& t) //output operator
{
outputObj<<t.hour <<":" <<t.mins;
return outputObj;
}