-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCDate.h
More file actions
54 lines (47 loc) · 1.06 KB
/
CDate.h
File metadata and controls
54 lines (47 loc) · 1.06 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
#pragma once
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
class CDate
{
private:
int day;
int month;
int year;
static const int MonthsInYear[13];
static const int DaysInMonth[13];
bool isLeapYear(int year) { // Check leap year
return (year % 100) ? (year % 4 == 0) : (year % 400 == 0);
}
public:
CDate() {
day = month = year = 0;
}
void setDate(int d, int m, int y) {
day = d;
month = m;
year = y;
}
void setDay(int d) {
day = d;
}
void setMonth(int m) {
month = m;
}
void setYear(int y) {
year = y;
}
friend ostream& operator << (ostream&, const CDate);
friend istream& operator >> (istream&, CDate&);
int countLeapYears();
int operator -(CDate); // TimeSpan
CDate operator + (int); // Cộng với một giá trị ngày bất kỳ
CDate operator - (int); // Trừ cho một giá trị ngày bất kỳ
CDate operator ++ ();
CDate operator ++ (int);
CDate operator -- ();
CDate operator -- (int);
~CDate() {};
};
void Menu(CDate, CDate);