日期类,日期相减,实现日期的下一天
两个日期 相减
日期 + 天数 得到的日期
具体要求:实现类date,其中
构造函数包括year,month,day三个参数
重载两个date类之间的-,以及date类的+=,-=
使用int year(),int month(),int day()返回三个参数
#include <iostream>
using namespace std;
class date {
private:
int y;
int m;
int d;
public:
date(int, int, int);
int year();
int month();
int day();
date operator++ ();
date operator++ (int);
date operator-- ();
date operator-- (int);
friend int operator- (const date &dt1, const date &dt2);
friend void operator+= (date &dt, const int n);
friend void operator-= (date &dt, const int n);
};
date::date(int year = 0, int month = 0,