不知道哪里错了,请大神帮忙改一下
#include <iostream>using namespace std;
class Date
{ public:
Date(int y, int m, int d);
void display();
Date operator ++();
Date operator ++(int);
friend Date operator --(Date &);
friend Date operator --(Date &,int);
private:
int year;
int month;
int day;
}
Date::Date(int y, int m, int d)
{ y=year;
m=month;
d=day;
}
void Date::display()
{cout<<year<<"年"<<month<<"月"<<day<<"日"<<endl;}
Date Date::operator ++()
{++year;++month;++day;
return *this;
}
Date Date::operator ++(int)
{Date temp(*this);
year++;month++;day++;
return temp;
}
Date operator --(Date &op)
{--op.year;--op.month;--op.day;
return op;
}
Date operator --(Date &op,int)
{ op.year--;op.month--;op.day--;
return op;
}
int main()
{Date dt1(2016,5,12);
cout<<"dt1的原值 :";
dt1.display();
++dt1;
cout<<"执行++dt1后的dt1的值: ";
dt1.display();
dt1++;
cout<<"执行dt1++后的dt1的值: ";
dt1.display();
--dt1;
cout<<"执行--dt1后的dt1的值: ";
dt1.display();
dt1--;
cout<<"执行dt1--后的dt1的值: ";
dt1.display();
return 0;
}