-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path03_date.cpp
88 lines (73 loc) · 1.53 KB
/
03_date.cpp
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// // Define a class Date and write a program to Display Date and initialize date object using Constructors.
// // Header files
#include <iostream>
// // use namespace
using namespace std;
// // define class Date
class Date
{
private:
// // instance member variables
unsigned int day;
unsigned int month;
unsigned int year;
public:
// // constructors
Date()
{
day = 1;
month = 1;
year = 1;
}
Date(int d)
{
day = d;
month = 1;
year = 1;
}
Date(int d, int m)
{
day = d;
month = m;
year = 1;
}
Date(int d, int m, int y)
{
day = d;
month = m;
year = y;
}
// // instance member function to set tate
void setDate(int d, int m, int y)
{
day = d;
month = m;
year = y;
}
// // instance member function to display tate
void displayDate()
{
cout << "\n"
<< day << "/" << month << "/" << year << endl;
}
};
// // Main Function Start
int main()
{
int day, month, year;
// // get date
cout << "\n>>>>>>>> Enter Date <<<<<<<\n";
cout << "\nEnter Day => ";
cin >> day;
cout << "\nEnter Month => ";
cin >> month;
cout << "\nEnter Year => ";
cin >> year;
Date t1(day, month, year); // create object of Date
cout << "\n>>>>>>>> Entered Date <<<<<<<<<";
t1.displayDate(); // display tate
cout << endl; // Add new line
cin.ignore();
return 0;
}
// // Main Function End