全国计算机等级考试二级C笔试试题.doc





《全国计算机等级考试二级C笔试试题.doc》由会员分享,可在线阅读,更多相关《全国计算机等级考试二级C笔试试题.doc(15页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、优质文本2016年3月 二级C+真题及参考答案一、选择题每题2分,共70分11对C+编译器区分重载(zhn zi)函数无任何意义的信息是 A参数类型 B参数个数 C返回值类型 D常成员函数关键字coast 12有如下类定义和变量定义: class A publie: Adata=0; A int GetData coast return data; void SetDataint n data=n; private: int data; ; ccnst A a; A b; 以下函数调用中错误的选项是 Aa .GetData; Ba .SetData10; Cb .GetData; Db .Se
2、tData10; 13有如下类定义和变量定义: class Parents public: int publicuata; private: int privateData; ; class ChildA:public Parents/*类体略*/; class ChildB:private Parents/*类体略*/; ChildA a; ChildBb; 以下语句中正确的选项是 Acouta.publicData endl ; Bcouta.privateData endl ; Ccoutb.publicData endl ; Dcoutb.privateData open“; 17以下
3、描述中,不属于面向对象思想主要特征的是 A封装性 B跨平台性 C继承性 D多态性 18有如下程序段: Tnt i=4;int j=l; int main int i=8,j=i; coutijendl; 运行时的输出结果是 A44 B41 C88 D81 19有如下程序段: int i=5; whileint i=0cout?*;i-; 运行时输出“*的个数是 A0 B1 C5 D无穷 20己知有数组定义(dngy) char a34; 以下表达式中错误的选项是 Aa2=“WIN Bstrcpya2,“WIN Ca 23=W Da01=a01 21函数fun的原型为 int funint,in
4、t,int; 以下重载函数原型中错误的选项是 Achar funint,int; Bdouble funint,int,double; Cint funint,char*; Dfloat fun int, int, int; 22建立一个类对象时,系统自动调用 A析构函数 B构造函数 C静态函数 D友元函数 23通过派生类的对象可直接访问其 A公有继承基类的公有成员 B公有继承基类的私有成员 C私有继承基类的公有成员 D私有继承基类的私有成员 24己知表达式+a中的“+是作为成员函数重载的运算符,那么与十+a等效的运算符函数调用形式为 Aa .orerator+1 Boperator+a Co
5、perator+a,l Da.operator+ 25在定义一个类模板时,模板形参表是用一对括号括起来的,所采用的括号是 A B C D 26当使用ifstream流类定义一个流对象并翻开一个磁盘文件时,文件的默认翻开方式为 Aios_base:in Bios_base:in|ios_base:out Cios_base:out Dios_base:in&ios_base:out 27有如下程序: #include #include using namespace std; class XCD char* a; int b; public: XCDchar* aa, int bb a=new
6、charstrlenaa+1; strcptya,aa; b=bb; Char* Geta return a; int Getb return b; ; int main char *pl=“abcd,*p2=“weirong; int dl=6, d2=8; XCD xpl,dl,Yp2,d2; coutstrien x .Geta+y. Getb+endl; return 0; 运行时的输出结果是 A12 B16 C14 D11 28有如下程序: #include #include using namespace std; class XCF int a; public: XCFint a
7、a=0:a aacout“1; XCFXCF& xa=x .a; cout“2; XCFcouta; int Getareturn a; ; int main XCF dl5,d7 dl; XCF *pd=new XCF8; coutGeta; delete pd; return 0; 运行时的输出结果是 A121SS88 B12188SS C12185 D128512 29类MyClass声明(shngmng)如下: class MyClass int n; public; MyClassint k:nk int getValueconstreturn n; ; 在以下数组定义中正确的选项是
8、 AMyClass x12; BMyClass x22=new MyClass1,new MyClass2; CMyClass *x32; DMyClass *x42=MyClass1,MyClass2; 30有如下程序: #include using namespace std; class AA lilt k; protected: int n; void setKint k this-k=k; public: void setNint n this-n=n; ; class BB: public /*类体略*/; int main BB x_ ; /1 x .n=1; /2 x.setN
9、 2; /3 x.k=3; /4 x .setK4; return 0; 在标注号码的四条语句中正确的选项是 A1 B2 C3 D4 31有如下类定义: class XX int xx; public: XX:xx0cout A; XXint n:xx ntout B; ; Class YY:public XX Int yy; public: YY:yy 0cout+yy; YYint n:XXn+1,yyncoutyy; YY int m, int n:XX m,yyncoutyy; ; 以下选项中,输出结果为A0的语句是 AYY y10,0; BYY y21; CYY y30; DYY y
10、4; 32有如下程序: #include Using namespace std; class A public: virtual void fcout+1; void gcout2; ; class B:public A public: virtual void fcout3; void gecut4; ; void showA &aa.f;a.g ; int main B b; showb; return 0; 运行时的输出结果是 A12 B34 C14 D32 33有如下(rxi)程序: #include using namespace std; class Pair int m; in
11、t n; public: Pairint i,int j:mi,nj boot operator pair pconst; /须在类体外给出定义 ; int main Pair Al3,4,p24,3;p34,5; Coutp2P1p3p2; return 0; 运算符函数。operator的功能是比拟两个Pair对象的大小,当左边对象大时,返回true,否那么返回false。比拟规那么是首先比拟两对象的m成员,m大者为大;当m相等时比拟n,n大者为大。程序输出0101,以下对运算符重载函数的正确定义是 Abool Pair:operatorPair pconst if m!=p.m retu
12、rn mp.m; return np.n; Bbool Pair:;operatorPair p if m!=p.m return mp.m; return np.n; Cbool Pair:operatorPair pconst if mp.m return true; return np.n; Dbool Pair:;operatorPair p if mp.m return true; return np.n; 34假定以下语句都是程序运行后首次执行的输出语句,其中输出结果与另外三条语句不同的语句是 Acoutsetfill*123setw9321; Bcoutsetfill*setw6
13、left123setw6right321; Ccout123setfill*setw6321; Dcoutsetfill*SetW9left123321; 35有如下程序: #include using namespace std; class ONE int c; public: ONE:c0cout1; ONEint n:c ncout2; ; class TWO ONE onel; ONE one2; public: TWOint m:one2mcout3; ; int maint TWO t4 return 0 运行时的输出结果是 A3 B23 C123 D213 二、填空题每空2分,
14、共30分 6有如下程序段: int x=1,Y=2,z=3; x=xz; y=yz; z=xy; coutxyz; 执行这个程序段的输出是【6】。 7有如下(rxi)程序段: ferint i=1; i=50;i+ ifi%3 != 0 continue; else ifi%5!=0 continue; touti“,; 执行这个程序段的输出是【7】。 8有如下程序段: Char c 20=“examination; c4=0; coutcendl; 执行这个程序段的输出是【8】。 9下面的函数利用递归实现了求1+2+3+n的功能: int sumint n ifn=0 return 0; e
15、lse return n+sumn-1; 在执行sum10的过程中,递归调用sum函数的次数是【9】。 10非成员函数应该声明为类【10】函数才能访问该类的私有成员。11有如下程序: #include using namespace std; class Monitor public: Monitorchar t:type t void print const cout“The type of monitor istypeendl; private: char type; ; class Computer public: Computerint i,char c: 【11】 void Prin
16、tconst cout“The computer isidendl;mon.Print; private: int id; Monitor mon; ; const Computer myComputer101,B; myComputer .Print; return 0; 请将程序补充完整,使程序在运行时输出: The computer is 101 The type of monitor i.s 8 12有如下程序: #include using namespace std class Animal public: virtual char* getTypeconst return “An
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 全国 计算机等级考试 二级 笔试 试题

限制150内