《面向对象程序设计C++》期末试卷(A)标准答案 - 副本【DOC精选】.docVIP

  • 1
  • 0
  • 约1.9千字
  • 约 3页
  • 2017-02-16 发布于江苏
  • 举报

《面向对象程序设计C++》期末试卷(A)标准答案 - 副本【DOC精选】.doc

(面向对象A卷答案)1-5.C D B C C  6-10.A A D D B11-15. B B C  6-20.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) 11. A operator++(int) 1、a=89,b=56,c=12 2、ABC 3、A::A() called. B::B() called. B::~B() called. A::~A() called.Call Bs function f() Call Bs function g() Call Cs function g() 1、(10分) Complex::Complex(){real=0;imag=0;} Complex::Complex(double r){real=r;} Complex::Complex(double r,double i){real=r;imag=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)endl; return output; } istream operator (istream input,Complex c) { coutinput real and imaginary part of complex number:; inputc.realc.imag; return input; } 2、(17分) class Circle:public Shape {public: Circle(double r){radius=r;} void set() { coutPlease input the value of the circle:endl; cinradius; } void show() { coutthe radius of the circle=radiusendl; } double area() {return 3.14159*radius*radius;} private: double radius; }; class Square:public Shape {public: Square(double a){this-a=a;} void set() { coutPlease input the value of a:endl; cina; } 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;} 1 第 3 页

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档