欢迎来到天天文库
浏览记录
ID:41970078
大小:43.50 KB
页数:3页
时间:2019-09-05
《《面向对象程序设计C++》期末试卷(A)标准答案 - 副本》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、(面向对象A卷答案)1-5.CDBCC 6-10.AADDB11-15.ABBBC 16-20.DCBCC1.抽象实例2.this指针3.ED、FA、B、C、D、ED、F4.virtual5.静态多态性动态多态性6.抽象类7.friendvoidfun(A&a)8.继承组合或模板9.在对象被系统释放之前做一些内存清理工作10.A(constA&)11.Aoperator++(int)1、a=89,b=56,c=122、ABC3、A::A()called.B::B()called.B::~B()called.A:
2、:~A()called.4、CallB'sfunctionf()CallB'sfunctiong()CallC'sfunctiong()1、(10分)Complex::Complex(){real=0;imag=0;}Complex::Complex(doubler){real=r;}Complex::Complex(doubler,doublei){real=r;imag=i;}Complexoperator+(Complex&c1,Complex&c2){Complexc;c.real=c1.real+c2
3、.real;c.imag=c1.imag+c2.imag;returnc;第3页}ostream&operator<<(ostream&output,Complex&c){output<<"("<>(istream&input,Complex&c){cout<<"inputrealandimaginarypartofcomplexnumber:";input>>c.real>>c.im
4、ag;returninput;}2、(17分)classCircle:publicShape{public:Circle(doubler){radius=r;}voidset(){cout<<"Pleaseinputthevalueofthecircle:"<>radius;}voidshow(){cout<<"theradiusofthecircle="<5、bleradius;};classSquare:publicShape{public:Square(doublea){this->a=a;}voidset(){cout<<"Pleaseinputthevalueofa:"<>a;}voidshow()第3页{cout<<"a="<6、hape*s[]={&C,&S};cout<<"total="<
5、bleradius;};classSquare:publicShape{public:Square(doublea){this->a=a;}voidset(){cout<<"Pleaseinputthevalueofa:"<>a;}voidshow()第3页{cout<<"a="<6、hape*s[]={&C,&S};cout<<"total="<
6、hape*s[]={&C,&S};cout<<"total="<
此文档下载收益归作者所有