-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate.cpp
More file actions
65 lines (60 loc) · 1.22 KB
/
date.cpp
File metadata and controls
65 lines (60 loc) · 1.22 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
58
59
60
61
62
63
64
65
#include "date.h"
#include <string>
using namespace std;
date::date() // default constructor
{
day = 00;
month = 00;
year = 00;
}
date::date(int d, int m, int y) // non-default constructor
{
day = d;
month = m;
year = y;
}
void date::setDay(int d) // set method to get the day
{
day = d;
}
void date::setMonth(int m) // set method to get the month
{
month = m;
}
void date::setYear(int y) //set method to get the year
{
year = y;
}
void date::setDate(int d, int m , int y) //set method to get the date
{
day = d;
month = m;
year = y;
}
int date::getDay()const //get method to return the day
{
return day;
}
int date::getMonth()const // const method to return the month
{
return month;
}
int date::getYear()const // const method to return the year
{
return year;
}
void date::print()const // const method to print out the screen
{
cout <<day<<"/"<<month<<"/"<<year;
}
istream& operator >>(istream& inputObj , date& d) //input operator
{
inputObj >>d.day>>d.month>>d.year;
return inputObj;
}
ostream& operator <<(ostream& outputObj , const date& d) //output operator
{
outputObj<<d.day<<"/"<<d.month<<"/"<<d.year;
outputObj<<endl;
return outputObj;
}