欢迎来到天天文库
浏览记录
ID:40817229
大小:16.34 KB
页数:5页
时间:2019-08-08
《华中科技大学 类的上机答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第四章上机第一套第一题:classRectangle{private:doubleleft;doubletop;doubleright;doublebottom;public:Rectangle(doublea=0,doubleb=0,doublec=0,doubled=0);~Rectangle(){};voidAssign(doublea,doubleb,doublec,doubled);voidShow();doublegetLeft(){returnleft;};doublegetTop(){returntop;};doublege
2、tRight(){returnright;};doublegetBottom(){returnbottom;};doubleArea();doublePerimeter();};Rectangle::Rectangle(doublea,doubleb,doublec,doubled){left=a;top=b;right=c;bottom=d;}voidRectangle::Assign(doublea,doubleb,doublec,doubled){left=a;top=b;right=c;bottom=d;}voidRectangle
3、::Show(){cout<<"left-toppointis("<4、me,charsex,intbirthday,char*homeadd){strcpy(IdPerson,id);strcpy(Name,name);Sex=sex;Birthday=birthday;strcpy(HomeAddress,homeadd);}Person::Person(){IdPerson[0]=' ';Name[0]=' ';Sex=mid;Birthday=0;HomeAddress[0]=' ';}Person::Person(Person&Ps){cout<<""<5、,Ps.IdPerson);strcpy(Name,Ps.Name);Sex=Ps.Sex;Birthday=Ps.Birthday;strcpy(HomeAddress,Ps.HomeAddress);}第三题classTimedate{private:intyear,month,date;inthh,mm,ss;public:Timedate(int=2000,int=1,int=1);voidputdate(inty,intm,intd);voidputtime(intn,intm,ints);voidlist();};Timedat6、e::Timedate(inty,intm,intd){year=y;month=m;date=d;hh=12;mm=30;ss=0;}voidTimedate::putdate(inty,intm,intd){year=y;month=m;date=d;}voidTimedate::puttime(inth,intm,ints){hh=h;mm=m;ss=s;第四题#include#includeusingnamespacestd;constdoublePI=3.14159265;classCircle{7、private:doubler;doubleCircumference;doubleArea;public:Circle(doublea=0);Circle(Circle&);voidSetR(doubleR);~Circle(){};doubleGetR(){returnr;};doubleGetCircumference(){returnCircumference;};doubleGetAreaCircle(){returnArea;};};Circle::Circle(doublea){r=a;Area=PI*r*r;Circumfe8、rence=2*PI*r;}Circle::Circle(Circle&cl){r=cl.r;Area=cl.Area;Circumference=cl.Circumferenc
4、me,charsex,intbirthday,char*homeadd){strcpy(IdPerson,id);strcpy(Name,name);Sex=sex;Birthday=birthday;strcpy(HomeAddress,homeadd);}Person::Person(){IdPerson[0]=' ';Name[0]=' ';Sex=mid;Birthday=0;HomeAddress[0]=' ';}Person::Person(Person&Ps){cout<<""<5、,Ps.IdPerson);strcpy(Name,Ps.Name);Sex=Ps.Sex;Birthday=Ps.Birthday;strcpy(HomeAddress,Ps.HomeAddress);}第三题classTimedate{private:intyear,month,date;inthh,mm,ss;public:Timedate(int=2000,int=1,int=1);voidputdate(inty,intm,intd);voidputtime(intn,intm,ints);voidlist();};Timedat6、e::Timedate(inty,intm,intd){year=y;month=m;date=d;hh=12;mm=30;ss=0;}voidTimedate::putdate(inty,intm,intd){year=y;month=m;date=d;}voidTimedate::puttime(inth,intm,ints){hh=h;mm=m;ss=s;第四题#include#includeusingnamespacestd;constdoublePI=3.14159265;classCircle{7、private:doubler;doubleCircumference;doubleArea;public:Circle(doublea=0);Circle(Circle&);voidSetR(doubleR);~Circle(){};doubleGetR(){returnr;};doubleGetCircumference(){returnCircumference;};doubleGetAreaCircle(){returnArea;};};Circle::Circle(doublea){r=a;Area=PI*r*r;Circumfe8、rence=2*PI*r;}Circle::Circle(Circle&cl){r=cl.r;Area=cl.Area;Circumference=cl.Circumferenc
5、,Ps.IdPerson);strcpy(Name,Ps.Name);Sex=Ps.Sex;Birthday=Ps.Birthday;strcpy(HomeAddress,Ps.HomeAddress);}第三题classTimedate{private:intyear,month,date;inthh,mm,ss;public:Timedate(int=2000,int=1,int=1);voidputdate(inty,intm,intd);voidputtime(intn,intm,ints);voidlist();};Timedat
6、e::Timedate(inty,intm,intd){year=y;month=m;date=d;hh=12;mm=30;ss=0;}voidTimedate::putdate(inty,intm,intd){year=y;month=m;date=d;}voidTimedate::puttime(inth,intm,ints){hh=h;mm=m;ss=s;第四题#include#includeusingnamespacestd;constdoublePI=3.14159265;classCircle{
7、private:doubler;doubleCircumference;doubleArea;public:Circle(doublea=0);Circle(Circle&);voidSetR(doubleR);~Circle(){};doubleGetR(){returnr;};doubleGetCircumference(){returnCircumference;};doubleGetAreaCircle(){returnArea;};};Circle::Circle(doublea){r=a;Area=PI*r*r;Circumfe
8、rence=2*PI*r;}Circle::Circle(Circle&cl){r=cl.r;Area=cl.Area;Circumference=cl.Circumferenc
此文档下载收益归作者所有