#include <iostream>
using namespace std;
class date{
public:
date();
date(int y,int m, int d);
~date();
date(date &d);
void settime(int y,int m,int d);
void showtime();
private:
int year;
int month;
int day;
};
date::date()
{
year=2000;
month=1;
day=1;
cout<<"无参构造函数被调用"<<endl;
}
date::date(int y,int m,int d)
{
year=y;
month=m;
day=d;
cout<<"带参构造函数被调用"<<endl;
}
date::~date()
{
cout<<"析构函数被调用"<<endl;
}
date::date(date &d)
{
year=d.year;
month=d.month;
day=d.day;
cout<<"拷贝构造函数被调用"<<endl;
}
void date::settime(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
void date::showtime()
{
cout<<year<<"年"<<month<<"月"<<day<<"日"<<endl;
}
date getdate(date x)
{
return x;
}
int main()
{
date a;
date c(2015,4,25);
date b(a);
a.showtime();
b.showtime();
c.showtime();
b.settime(2015,1,1);
b.showtime();
system("pause");
}