2009年全国计算机等级考试二级C++笔试模拟题(三)(一)

时间:2011-02-25 15:25:17

微信搜索关注"91考试网"公众号,领30元,获取事业编教师公务员等考试资料40G
1、 有如下函数定义:void func (int a,int&B. {a++; b++;}若执行代码段:intx=0 ,y=1func(x,y);则变量x和y值分别是

A.0和1

B.1和1

C.0和2

D.1和2

参考答案: C

0和2

----------------------------------------

2、 有如下程序:#includeusing namespace std;Class A{publicstatic int a;void init(){a=1;}A(int a=2) {init();a++;}};int A:;a=0A obj;Int main(){Cout<A.0

B.1

C.2

D.3

参考答案: C

2

----------------------------------------

3、 下列有关继承和派生的叙述中,正确的是

A.派生类不能访问基类的保护成员

B.作为虚基类的类不能被实例化

C.派生类应当向基类的构造函数传递参数

D.虚函数必须在派生类中重新实现

参考答案: C

派生类应当向基类的构造函数传递参数

----------------------------------------

4、 下列运算符中,不能被重载的是

A.&&

B.!=

C..

D.++

参考答案: C

----------------------------------------

5、 下列函数模板的定义中,合法的是

A. template Tabs(T x) {return x <0 – x:x;}

B.template class Tabs(Tx){retumx<0-x;x;}

C.template Tabs(T x){retum x<0 -x;x;}

D.template T abs(T x){returm x<0 -x;x;}

参考答案: A

template Tabs(T x) {return x <0 – x:x;}

----------------------------------------

6、 在语句cin>>data;中,cin是

A.C++的关键字

B.类名

C.对象名

D.函数名

参考答案: C

对象名

----------------------------------------

7、 有如下程序:#includeusing namespace std;Class test {private:int a;public:test(){cout<<”constructor”<A.3

B.constructor

C.copy constructor

D.3 dstructor destruclor

DESTRUCLOR.

参考答案: D

3 dstructor destruclor

----------------------------------------

8、 若有如下类声明Class My Class {public:MyClass() {cout<<1;}};执行下列语句MyClass a,b[2],*P[2];以后,程序的输出结果是

A.11

B.111

C.1111

D11111.

参考答案: B

111

----------------------------------------

9、 有如下程序:#includeusing namespace std;Class point {public:static int number;public:point(){number++;~point(){number-;}};imt point::number=0;void main(){point*ptr;printA,B;{point*ptr_point=new point{3};ptr=ptr_point;}pointC;Cout<A.3

B.4

C.6

D.7

参考答案: D

7

----------------------------------------

10、 如果不使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员,有如下程序,没有使用多

首页 上页 1 2 下页 尾页 1/2/2
微信搜索关注"91考试网"公众号,领30元,获取公务员事业编教师考试资料40G
【省市县地区导航】【考试题库导航】

电脑版  |  手机版  |  返回顶部