写程序功能#include #include #include enum YR{Y2000,Y2001,Y2002,Y2003,Y2004,Y2005};//枚举名必须是标识符 enum MT{Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec}; class Timedate{ private: YR year; MT month; int date; int hh; int mm; int ss; public: Timedate(){year=Y2000;month=Jan;date=1;hh=0;mm=0;ss=0;} Timedate(YR a,MT b,int c){ year=a; month=b; date=c; hh=12;mm=30;ss=0;} void getdate(YR &,MT &,int &);//体会用引用的优点,一次可返回3个值void gettime(int &,int &,int &); void putdate(YR ,MT ,int ); void puttime(int ,int ,int ); void list(); }; void Timedate::getdate(YR &y,MT &m,int &d){ y=year; m=month; d=date; } void Timedate::gettime(int &a,int &b,int &c){ a=hh; b=mm; c=ss; } void Timedate::putdate(YR a,MT b,int c){ year=a; month=b; date=c; }void Timedate::puttime(int a,int b,int c){ hh=a; mm=b; ss=c; } void Timedate::list(){//成员函数cout<<"year/month/date :"; switch(year){ case Y2000:cout<<"2000";break; case Y2001:cout<<"2001";break; case Y2002:cout<<"2002";break; case Y2003:cout<<"2003";break; case Y2004:cout<<"2004";break; case Y2005:cout<<"2005";break; } switch(month){case Jan:cout<<'/'<<"Jan";break; case Feb:cout<<'/'<<"Feb";break; case Mar:cout<<'/'<<"Mar";break; case Apr:cout<<'/'<<"Apr";break; case May:cout<<'/'<<"May";break; case Jun:cout<<'/'<<"Jun";break; case Jul:cout<<'/'<<"Jul";break; case Aug:cout<<'/'<<"Aug";break; case Sep:cout<<'/'<<"Sep";break; case Oct:cout<<'/'<<"Oct";break; case Nov:cout<<'/'<<"Nov";break; case Dec:cout<<'/'<<"Dec";break; } cout<<'/'<
写程序功能#include #include #include enum YR{Y2000,Y2001,Y2002,Y2003,Y2004,Y2005};//枚举名必须是标识符 enum MT{Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec}; class Timedate{ private: YR year; MT month; int date; int hh; int mm; int ss; public: Timedate(){year=Y2000;month=Jan;date=1;hh=0;mm=0;ss=0;} Timedate(YR a,MT b,int c){ year=a; month=b; date=c; hh=12;mm=30;ss=0;} void getdate(YR &,MT &,int &);//体会用引用的优点,一次可返回3个值void gettime(int &,int &,int &); void putdate(YR ,MT ,int ); void puttime(int ,int ,int ); void list(); }; void Timedate::getdate(YR &y,MT &m,int &d){ y=year; m=month; d=date; } void Timedate::gettime(int &a,int &b,int &c){ a=hh; b=mm; c=ss; } void Timedate::putdate(YR a,MT b,int c){ year=a; month=b; date=c; }void Timedate::puttime(int a,int b,int c){ hh=a; mm=b; ss=c; } void Timedate::list(){//成员函数cout<<"year/month/date :"; switch(year){ case Y2000:cout<<"2000";break; case Y2001:cout<<"2001";break; case Y2002:cout<<"2002";break; case Y2003:cout<<"2003";break; case Y2004:cout<<"2004";break; case Y2005:cout<<"2005";break; } switch(month){case Jan:cout<<'/'<<"Jan";break; case Feb:cout<<'/'<<"Feb";break; case Mar:cout<<'/'<<"Mar";break; case Apr:cout<<'/'<<"Apr";break; case May:cout<<'/'<<"May";break; case Jun:cout<<'/'<<"Jun";break; case Jul:cout<<'/'<<"Jul";break; case Aug:cout<<'/'<<"Aug";break; case Sep:cout<<'/'<<"Sep";break; case Oct:cout<<'/'<<"Oct";break; case Nov:cout<<'/'<<"Nov";break; case Dec:cout<<'/'<<"Dec";break; } cout<<'/'<