第六章单元测试
  1. 虚继承主要作用是解决多重继承中二义性的问题。( )

  2. A:对 B:错
    答案:对
  3. 以下成员函数表示纯虚函数的是 ( )

  4. A:virtual int vf(int); B:virtual void vf(int) {} C:void vf(int) = 0; D:virtual void vf() = 0;
  5. 若一个类中含有纯虚函数,则该类称为 ( )

  6. A:抽象类 B:派生类 C:虚基类 D:友元类
  7. 在派生类中,编写一个虚函数时,要求函数名、参数的个数、参数的类型、参数的顺序和函数的返回值 ( )

  8. A:相同 B:根据程序开发者意图而定 C:部分相同 D:不同
  9. 基类指针可以指向派生类对象,派生类指针也可指向基类对象。( )

  10. A:错 B:对
  11. When a class is derived from a class with a pure virtual function and no definition is supplied for that pure virtual function in the derived class, that derived class is also an abstract class. ( )

  12. A:对 B:错
  13. Choose the correct statement? ( )

  14. A:Abstract class cannot be inherited B:Abstract class cannot have normal functions. C:Abstract class is a class which contains at least one Pure Virtual function in it. D:Abstract class can be instantiated.
  15. #include<stdio.h>
    class Base{
    public:
    virtual void show() {printf("In Base; "); }
    };
    class Derived: public Base{
    public:
    void show() { printf("In Derived; "); }
    };
    void main(){
    Base *bp = new Derived;
    bp->show();
    }
    Output? ( )

  16. A:In Base; In Derived; B:In Derived; In Base; C:In Base; D:In Derived;

温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!
点赞(2) dxwkbang
返回
顶部