写一个简单的日期类实现日期计算器功能:
1 给一个日期计算这个日期加上一个天数后是哪一天
2 给一个日期计算这个日期减去一个天数后是哪一天
3 给定两个日期,求这两个日期中间相隔多少天
Date.h
#ifndef __DATE_H__
#define __DATE_H__
#define _CRT_SECURE_NO_DEPRECATE 1
#include<iostream>
#include<stdlib.h>
using namespace std;
class Date
{
public:
Date(int year=1900, int month=1, int day=1)
{
this->_year = year;
this->_month = month;
this->_day = day;
}
Date(const Date& d)
{
this->_year = d._year;
this->_month = d._month;
this->_day = d._day;
}
~Date()
{
;
}
Date& operator=(const Date& d)
{
if(this != &d)
{
this->_year = d._year;
this->_month = d._month;
this->_day = d._day;
}
return *this;
}
void Print_Date();
int GetMonthDay(int year, int month);
bool CheckLegality();
Date& operator+=(int day); //求某个日期day天后的日期是哪一天
Date& operator-=(int day); //求某个日期day天前的日期是哪一天
bool operator>(const Date& d);
bool operator&#