3.24作业
2015-04-08 13:58
330 查看
#include<iostream> using namespace std; class Date { public : void printDate(); void GetYear(); void GetMonth(); void GetDay(); void SetDate(int Y,int m,int d); private : int year; int month; int day; }; void Date::printDate() { cout<<year<<"年"<<month<<"月"<<day<<"日"<<endl; } void Date::GetYear() { cout<<year<<"年"<<endl; } void Date::GetMonth() { cout<<month<<"月"<<endl; } void Date::GetDay() { cout<<day<<"日"<<endl; } void Date::SetDate(int Y,int m,int d) { year=Y; month=m; day=d; } int main() { Date d1; d1.SetDate(2010,6,8); d1.printDate(); d1.GetYear(); d1.GetMonth(); d1.GetDay(); Date d2; Date d3(d1); d3.printDate(); return 0; }