1、面向对象程序设计C+期末考试试卷(A)标准答案班级: 姓名: 学号: 分数: 题号一二三四总分得分一、单项选择题(每小题2分,共40分)1-5C D B C C 6-10A A D D B 11-15A B B B C 16-20D C B C C二、填空题(前14个空,每空1分,后3个空,每空2分,共20分)1 抽象 实例 2 this指针 3 E D、F A、B、C、D、E D、F 4 virtual 5 静态多态性 动态多态性 6. 抽象类 7. friend void fun(A &a) 8. 继承 组合或模板 9. 在对象被系统释放之前做一些内存清理工作 10. A(const A&
2、) 11. A operator+(int) 三、阅读程序(13分)1、a=89,b=56,c=122、ABC3、A:A() called. B:B() called. B:B() called.A:A() called.4、Call Bs function f() Call Bs function g() Call Cs function g()四、编程题(共27分)1、(10分)Complex:Complex()real=0;imag=0;Complex:Complex(double r)real=r;Complex:Complex(double r,double i)real=r;ima
3、g=i;Complex operator+(Complex &c1,Complex &c2) Complex c; c.real=c1.real+c2.real; c.imag=c1.imag+c2.imag; return c;ostream& operator (ostream& output,Complex& c) output(c.real+c.imagi) (istream& input,Complex& c) coutc.realc.imag; return input;2、(17分)class Circle:public Shapepublic: Circle(double r)
4、radius=r;void set()coutPlease input the value of the circle:radius; void show()coutthe radius of the circle=radiusa=a;void set()coutPlease input the value of a:a; void show()couta=aendl; double area()return a*a;private:double a;int main()Circle C(5.5);C.show();Square S(9.9);S.show();Shape *s=&C,&S;couttotal=total(s,2)endl;return 0;第 4 页