#include<iostream>
#include<iomanip>
using namespace std;
class Date{
private:
int year;
int month;
int day;
public:
Date()
{year=1995;
month=8;
day=16;
}
Date(int y,int m,int d)
{year=y;
month=m;
day=d;
}
Date(const Date& i)
{year=i.year;
month=i.month;
day=i.day;
}
void Date::printDate()
{
cout<<"The date is:"<<year<<" "<<month<<" "<<day<<endl;
}
void Date::GetYear()
{ cout<<"year"<<year<<endl;
}
void Date::GetMonth()
{ cout<<"month:"<<month<<endl;
}
void Date::GetDay()
{ cout<<"day:"<<day<<endl;
}
void SetDate(int Y,int m,int d)
{
cout<<"请输入年份"<<endl;
cin>>year;
cout<<"请输月份"<<endl;
cin>>month;
cout<<"请输入日"<<endl;
cin>>day;
}
};
int main()
{
Date d1(2014,4,12);
Date d2;
d1.printDate();
cout<<"d1信息为:"<<endl;
d2=d1;
cout<<"d2信息为:"<<endl;
d2.printDate();
Date d3(d1);
cout<<"d3信息为:"<<endl;
d3.printDate();
return 0;
}
3.24
最新推荐文章于 2024-11-26 14:47:31 发布