-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday4_3.cpp
More file actions
72 lines (72 loc) · 1.05 KB
/
day4_3.cpp
File metadata and controls
72 lines (72 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<iostream>
using namespace std;
class Date
{
private:int day;
int mon;
int year;
public:Date(int d,int m,int y)
{
day=d;
mon=m;
year=y;
}
void display()
{
cout<<"The Date Is:"<<day<<"/"<<mon<<"/"<<year<<endl;
}
void operator++(int)
{
int flag=1;
day++;
if(mon==2)
{
if(year%4==0)
if(day==30)
{
day=1;
mon++;
return;
}
else
if(day==29)
{
day=1;
mon++;
return;
}
}
else if(mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12)
if(day==32)
{
day=1;
mon++;
if(mon==13)
{
mon=1;
year++;
}
return;
}
else
{
if(day==31)
{
day=1;
mon++;
return;
}
}
}
};
int main()
{
Date D1(29,02,2004);
Date D2(31,12,2005);
D1.display();
D1++;
D1.display();
D2.display();
D2++;
D2.display();
}