//复制构造函数也是构造函数
#include<iostream>
using namespace std;class Date{
private :
int year,month,day;
public :
Date(int y=2009,int m=1,int d=1);
Date(const Date &date);//????????
~Date()
{
cout<<"destructing..."<<endl;
};
void ShowDate();
};
Date::Date(int y, int m, int d)//???????
{
year=y;
month=m;
day=d;
cout<<"constructing..."<<endl;
};
Date::Date(const Date& date1)//???????
{
year=date1.year;
month=date1.month;
day=date1.day;
cout<<"Copy Constructing..."<<endl;
};
void Date::ShowDate()
{
cout<<year<<"."<<month<<"."<<day<<endl;
};
Date Fun(Date date2)//???????????
{
Date date3(date2);//?????????????
return date3;
}
int main()
{
Date obj1(1999,3,20);
Date obj3;
Date obj2(obj1);
Date obj4=obj2;//??????????????Date day4(day2)
Date obj5();//其实是调用拷贝函数
obj3=Fun(obj2);
obj3.ShowDate();
return 0;
}