设计一个日期类Date, 包括年月日,要求实现日期的基本运算, 如某个日期加上天数, 两个日期的间隔天数, 等。在程序中重载下运算符,这样比较直观:Date operator+(int days)Date operator-(int days)int operator-(Date &d;)私有成员函数:leap(int)dton(Date &) 指定日期到0-0-0开始的天数ntod(int) 将天数转换成日期more程序如下:#include#includeusingnamespacestd;intday_tab[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};classDate{private:intyear,month,day;intleap(int);intdton(Date&);Datentod(int);public:Date();Date(inty,intm,intd){year=y;month=m;day=d;}voidsetday(intd){day=d;}voidsetyear(inty){year=y;}voidsetmonth(intm){month=m;}intgetday(){returnday;}intgetyear(){
...
继续阅读
(1)