欢迎来到天天文库
浏览记录
ID:11571815
大小:28.00 KB
页数:4页
时间:2018-07-12
《《面向对象程序设计c++》期末试卷(b)标准答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、《面向对象程序设计C++》期末考试试卷(B)标准答案一、单项选择题(每小题2分,共40分)1-5.DACAD 6-10.DBCDC11-15.DCBDB 16-20.ADCCC二、填空题(前16个空,每空1分,后2个空,每空2分,共20分)1.抽象、实例2.public、private____、protected、private____3.virtual___4.friendvoidfun(A&a)_5.静态数据成员、静态成员函数6.结合性、优先级____7.Template、class(或typename)8.类、结构体___9.在创建对象时初始化对象的数据成员_
2、__10.Aoperator++(int)___三、阅读程序(共13分)1、a=89,b=56,c=122、12/31/200912/31/20091/1/20101/1/20103、constructingAconstructingBconstructingC第4页destructingCdestructingBdestructingA四、编程题(共27分)1、(10分)Complex::Complex(){real=0;imag=0;}Complex::Complex(doubler){real=r;}Complex::Complex(doubler,doubl
3、ei){real=r;imag=i;}Complexoperator+(Complex&c1,Complex&c2){Complexc;c.real=c1.real+c2.real;c.imag=c1.imag+c2.imag;returnc;}ostream&operator<<(ostream&output,Complex&c){output<<"("<>(istream&input,Complex&c){cout<<"inputrea
4、landimaginarypartofcomplexnumber:";input>>c.real>>c.imag;returninput;}2、(17分)classCircle:publicShape{public:Circle(doubler){radius=r;}第4页voidset(){cout<<"Pleaseinputthevalueofthecircle:"<>radius;}voidshow(){cout<<"theradiusofthecircle="<5、59*radius*radius;}private:doubleradius;};classSquare:publicShape{public:Square(doublea){this->a=a;}voidset(){cout<<"Pleaseinputthevalueofa:"<>a;}voidshow(){cout<<"a="<6、Shape*s[]={&C,&S};cout<<"total="<
5、59*radius*radius;}private:doubleradius;};classSquare:publicShape{public:Square(doublea){this->a=a;}voidset(){cout<<"Pleaseinputthevalueofa:"<>a;}voidshow(){cout<<"a="<6、Shape*s[]={&C,&S};cout<<"total="<
6、Shape*s[]={&C,&S};cout<<"total="<
此文档下载收益归作者所有