#include<iostream>
using namespace std;
int DayOfMonth[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
class Date
{
private:
int year;
int month;
int day;
public:
Date(int y=0,int m=0,int d=0):year(y),month(m),day(d){}
void Print()
{
cout<<"日期为:"<<"\t";
cout<<this->year<<"年"<<this->month<<"月"<<this->day<<"日"<<endl;
}
void SetDate(int y1,int m1,int d1)
{
year=y1;
month=m1;
day=d1;
}
int LeapYear()
{
return ( (this->year %4==0)&&(this->year %100!=0) || (this->year %400==0) );
}
void AddDay()
{
if( LeapYear() )
{
DayOfMonth[2]=29;
}
++day;
if(day>DayOfMonth[this->month])
{
++month;
day=1;
}
if(month>12)
{
++year;
month=1;
}
}
};
int main()
{
Date d;
d.SetDate (2010,12,31);
cout<<"没加天数前的时间为:"<<"\t";
d.Print ();
d.AddDay();
cout<<"加天数后的时间为:"<<"\t";
d.Print();
}