第二章单元测试
  1. 有关函数重载的正确说法是 ( )

  2. A:函数名相同,函数的返回值不同,而与函数的参数和类型无关 B:函数名相同,参数的个数和类型相同 C:函数名相同,但参数的个数不同或参数的类型不同 D:函数名不同,但参数的个数和类型相同
    答案:函数名相同,但参数的个数不同或参数的类型不同
  3. 使用运算符 . 可以访问名字空间里的函数。( )

  4. A:对 B:错
    答案:错
  5. 作用域运算符“::”的功能是 ( )

  6. A:标识成员是属于哪个类或哪个命名空间 B:指出作用域的范围的 C:给定作用域的大小的 D:标识作用域的级别的
    答案:指出作用域的范围的
  7. 适宜采用inline定义函数情况是 ( )

  8. A:函数体含有递归语句 B:函数体含有循环语句 C:函数代码少、频繁调用 D:函数代码多、不常调用
    答案:函数代码少、频繁调用
  9. 类A有如下成员函数:
    int A::fun(double x){return (int) x/2;}
    int A::fun(int x){return x*2;}
    设a为类A的对象,在主函数中执行语句int s = a.fun(6) + a.fun(2.0)后的s值 ( )

  10. A:4 B:13 C:5 D:7
    答案:13
  11. Which of the following is a valid inline for function foo? ( )

  12. A:None of the above B:void foo() inline {} C:inline:void foo() {} D:inline void foo() {}
    答案:inline void foo() {}
  13. #include<iostream>
    using namespace std;
    int fun(int x = 0, int y = 0, int z)
    {
    return (x + y + z);
    }
    int main()
    {
    printf("%d", fun(10));
    return 0;
    }
    Output? ( )

  14. A:20 B:10 C:0 D:Compiler Error
    答案:Compiler Error
  15. #include <iostream>
    using namespace std;
    int fun(int=0, int = 0)
    {
    return (x+y);
    }
    int main()
    {
    printf("%d", fun(5));
    return 0;
    }
    Output? ( )

  16. A:10 B:0 C:5 D:Compiler Error
    答案:5
  17. Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++. ( )

  18. A:Inheritance B:Polymorphism C:None of the above D:Encapsulation
    答案:Polymorphism
  19. #include <iostream>
    using namespace std;
    namespace T{
    class A {
    public:
    void show() {
    printf("Go");
    }
    };
    }
    int main(){
    T::A obj;
    obj.show();
    return 0;
    }
    Output? ( )

  20. A:0 B:No output C:Compilation Error D:Go
    答案:Go

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