#define _CRT_SECURE_NO_WARNINGS 1#include
#include
using namespace std;class Date{public:    Date(int year=0, int month=0, int day=0)    :_year(year)    , _month(month)    , _day(day)    {        cout << "构造函数" << endl;    }    Date( const Date& d)    {        cout << "拷贝构造函数" << endl;        _year = d._year;        _month = d._month;        _day = d._day;    }    /*Date& operater = (const Date& d)    {        cout << "运算符重载" <
_year == d._year            && this->_month == d._month            &&this->_day = d._month;    }     //大于    bool operator > (const Date& d)    {        if (this->_year > d._year)        {            return true;        }        else        {            if (this->_year == d._year)            {                if (this->_month > d._month)                {                    return true;                }                else                {                    if (this->_month == d._month)                    {                        if (this->_day > d._day)                        {                            return true;                        }                        else                        {                            return false;                        }                    }                    else                    {                        return false;                    }                }            }            else            {                return false;            }        }    }    //小于    bool operator < (const Date& d)    {        if (this->_year < d._year)        {            return true;        }        else        {            if (this->_year == d._year)            {                if (this->_month < d._month)                {                    return true;                }                else                {                    if (this->_month == d._month)                    {                        if (this->_day < d._day)                        {                            return true;                        }                        else                        {                            return false;                        }                    }                    else                    {                        return false;                    }                }            }            else            {                return false;            }        }    }     //大于等于    bool operator >= (const Date& d)    {        if (this->_year >= d._year)        {            return true;        }        else        {            return false;        }    }    //小于等于    bool operator <= (const Date& d)    {        if (this->_year <= d._year)        {            return true;        }        else        {            return false;        }    }    //Date operator+ (int day);    Date operator+ (int day)    {            }    void Display()    {        cout << _year << "-" << _month << "-" << _day<
= 0)            {                this->_day += day;                while (this->_day > GetMonthDay(2016, 5))                {                    rest = this->_day - GetMonthDay(2016, 2);                    if (this->_month != 12)                    {                        this->_month++;                    }                    else                    {                        this->_year++;                        this->_month = 1;                    }                    this->_day = rest;                }            }            else            {                Date operator - 50;            }            return *this;        }    //加天数,Date operator+= (int day);    Date operator+= (int day )    {        Date tmp(*this);        tmp._day += day;        int rest = 0;        if (day > 0)        {            while (tmp._day > GetMonthDay(2016, 5))            {                rest = tmp._day - GetMonthDay(2016, 2);                if (tmp._month != 12)                {                    tmp._month++;                }                else                {                    tmp._year++;                    tmp._month = 1;                }                tmp._day = rest;            }        }        else        {            Date operator-= 50;        }        return tmp;    }    //减天数,Date operator- (int day);    Date operator - (int day)    {        int rest = 0;        if (day <= 0)        {            this->_day -= day;            while (this->_day > GetMonthDay(2016, 5))            {                rest = this->_day - GetMonthDay(2016, 2);                if (this->_month != 1)                {                    this->_month--;                }                else                {                    this->_year--;                    this->_month = 12;                }                this->_day = rest;            }        }        else        {            Date operator + 50;        }        return *this;    }    //减天数,Date operator-= (int day);    Date operator-= (int day)    {        int rest = 0;        Date tmp(*this);        if (day <= 0)        {            tmp._day -= day;            while (tmp._day > GetMonthDay(2016, 5))            {                rest = tmp._day - GetMonthDay(2016, 2);                if (tmp._month != 1)                {                    tmp._month--;                }                else                {                    tmp._year--;                    tmp._month = 12;                }                tmp._day = rest;            }        }        else        {            Date operator + 50;        }        return tmp;    }    //前置++    Date operator++()    {        if (day > GetMonthDay(int year, int month))        {            if (month != 12)            {                ++this->day;            }            else            {                ++year;                month = 1;                day = 1;            }        }        else        {            ++day;        }        return *this;    }    //后置++    Date operator++(int)    {        Date tmp(*this);        tmp._day;        if (day > GetMonthDay(int year, int month))        {            if (month != 12)            {                ++tmp.day;            }            else            {                ++tmp.year;                tmp.month = 1;                tmp.day = 1;            }        }        else        {            ++tmp.day;        }        return tmp;    }    //前置--    Date operator++()    {        if (day > GetMonthDay(int year, int month))        {            if (month != 1)            {                ++this->day;            }            else            {                --year;                month = 12;                day = 1;            }        }        else        {            --day;        }        return *this;    }    //后置--    Date operator--(int)    {        Date tmp(*this);        tmp._day;        if (day > GetMonthDay(int year, int month))        {            if (month != 1)            {                --tmp.day;            }            else            {                --tmp.year;                tmp.month = 12;                tmp.day = 1;            }        }        else        {            --tmp.day;        }        return tmp;    }    ~Date()    {        cout << "析构函数" << endl;    }private:    int _year;    int _month;    int _day;};void Test1(){    Date d;    d.Display();    Date ret = operator + (50);}int main(){    Test1();    system("pause");    return 0;}