#include<iostream.h>
class Date{
public:
Date(){}
Date(int y,int m,int d)
{month=m;
day=d;
year=y;}
void print()
{cout<<year<<"."<<month<<"."<<day<<endl;
}
friend Date operator +(Date &op);
private:
int month,day,year;
};
Date operator+(Date &op)
{
++op.day;
return op;
}
int main()
{
Date d1(2014,5,17);
cout<<"改变日期前:";
d1.print();
cout<<"天数加1后:";
operator +(d1);
d1.print();
return 0;
}
c++ 7.11
最新推荐文章于 2021-05-14 17:28:29 发布