考试快讯考试真题
返回首页
当前位置: 主页 > 计算机 > 等级考试 > 考试真题 >

2010年3月计算机等级考试二级C++笔试试题(文字版(4)

时间:2010-04-02 22:10来源:未知 作者:admin 点击:
(27)下列程序段中包含4个函数,其中具有隐含this指针的是 int fun1(); class Test{ public: int fun2(); friend int fun3(); static int fun4(); }; A)fun1 B)fun2 C)fun3 D)fun4 (28)有如下

  (27)下列程序段中包含4个函数,其中具有隐含this指针的是

  int fun1();

  class Test{

  public:

  int fun2();

  friend int fun3();

  static int fun4();

  };

  A)fun1

  B)fun2

  C)fun3

  D)fun4

  (28)有如下程序

  #include

  using namespace std;

  class Test{

  public:

  Test(){ }

  Test(const Test &t) {cout<<1;}

  };

  Test fun(Test &u) {Test t=u; return t;}

  int main(){Test x,y; x=fun(y); return 0;}

  运行这个程序的输出结果是

  A)无输出

  B)1

  C)11

  D)111

  (29)有如下程序

  #include

  using namespace std;

  class A{

  public:

  A(int i=0):r1(i) { }

  void print() {cout<<'E’<

  void print() const {cout<<'C'<

  void print(int x) {cout <<'P'<

  private:

  int r1;

  };

  int main() {

  A a1;

  const A a2(4);

  a1.print(2);

  a1.print();

  return 0;

  }

  运行时的输出结果是

  A)P8-E4

  B)P8-C16-

  C)P0-E4-

  D)P0-C16-

  (30)下列代码声明了3个类

  class Person{};

  class Student:public Person{};

  class Undergraduate:Student{};

  下列关于这些类之间关系的描述中,错误的是

  A)类Person是类Undergraduate的基类

  B)类Undergraduate从类Student公有继承

  C)类Student是类Person的派生类

  D)类Undergraduate是类Person的派生类

(责任编辑:admin)

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
推荐内容