设为首页 加入收藏

TOP

2018年9月计算机二级C++考前基础练习试题(6)
2018-04-28 06:06:02 】 浏览:301
Tags:2018年 9月 计算机 二级 考前 基础 练习 试题

1.下列控制格式输入输出的操作符中,能够设置浮点数精度的是(  )。


A.setprecision


B.setw


C.setfill


D.showpoint


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


intfunl(  );


classTest{


public:


intfun2(  );


friendintfun3(  );


staticintfun4(  );


};


A.funl


B.fun2


C.fun3


D.fun4


3.有如下程序:


#include


usingnamespacestd;


classTest(


public:


Test(  ){}


Test(constTest8Lt){cout<<1;}


};


Testfun(Test&u){Testt=U;returnt;}


intmain(  ){Testx,y;x=fun(y);return0;}


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


A.无输出


B.1


C.1l


D.111


4.有如下程序:


#include


usingnamespacestd;


classA{


public:


A(inti=O):rl(i){}


voidprint(  ){cout<<’E’


voidprint(intx){cout<<’P’<-’;}


private:


intr1;


};


intmain(  ){


Aal:


constAa2(4);


a1.print(2);


a2.print(  );


return0;


}


运行时的输出结果是(  )。


A.P8一E4


B.P8一C16一


C.P0一E4一


D.P0一C16―


5.下列代码段声明了3个类:


classPerson{);


classStudent:publicPerson{};


classUndergraduate:Student{);


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


A.类Person是类Undergraduate的基类


B.类Undergraduate从类Student公有继承


C.类Student是类Person的派生类


D.类Undergraduate是类Person的派生类


6.有如下程序:


#include


Usingnamespacestd;


classBase{


public:


Base(intx=O):valB(x){cout<~Base(  ){cout


intvalB:


};


classDerived:publicBase{


public:


Derived(intX=0,inty=0):Base(x),valD(y)(cout<~Derived(  ){cout


intvalD;


};


intmain(  ){


Derivedobj12(2,3);


return0;


}


运行时的输出结果是(  )。


A.2332


B.2323


C.3232


D.3223


7.下面是类Shape的定义:


classShape{


public:


virtualvoidDraw(  )=0;


}


下列关于Shape类的描述中,正确的是(  )。


A.类Shape是虚基类


B.类Shape是抽象类


C.类Shape中的Draw函数声明有误


D.语句“ShapeS;”能够建立Shape的一个对象S


8.将运算符“+”重载为非成员函数,下列原型声明中,错误的是(  )。


A.MyClockoperator+(MyClock,long);


B.MyClockoperator+(MyClock,MyCloek);


C.MyCloekoperator+(long,long);


D.MyClockoperator+(long,MyCloek):


9.打开文件时可单独或组合使用下列文件打开模式:


①ios_base::aop


②ios_base::binary


③ios_base::


④ios_base::out


若要以二进制读方式打开一个文件,需使用的文件打开模式为(  )。


A.①③


B.①④


C.②③


D.②④


10.有如下程序:


#include


usingnamespacestd;


classB{


public:


B(intxx):x(xx){++count;x+=10;}


virtualvoidshow(  )const


{cout


staticintcount;


private:


intx;


};


classD:publicB{


public:


D(intxx,intyy):B(XX),y(yy){++count;y+=


100;)


virtualvoidshow(  )const


{cout


inty;


};


intB::count==0;


intmain(  ){


B*ptr=newD(10,20);


ptr->show(  );


deleteptr;


return0;


}


运行时的输出结果是(  )。


A.1_120


B.2_120


C.1_20


D.2_20


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇2018年9月计算机二级C++考前基础.. 下一篇2018年9月计算机二级C++考前基础..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目