资源预览内容
第1页 / 共6页
第2页 / 共6页
第3页 / 共6页
第4页 / 共6页
第5页 / 共6页
第6页 / 共6页
亲,该文档总共6页全部预览完了,如果喜欢就下载吧!
资源描述
xx年12月计算机二级C+练习题及答案 全国对于知识点的掌握是比较重要的,下面是为各位考生的xx年12月计算机二级C+练习题及答案,希望堵大家的考试有所帮助! (1)关于友元的概念错误的选项是 A)友元函数没有this指针 B)调用友元函数时必须在它的实参中给出要访问的对象 C)一个类的成员函数也可以作为另一个类的友元函数 D)只能在类的公有段声明友元 (2)关于抽象类下面说法正确的选项是 A)抽象类就是其中有函数定义但没有实现的类 B)抽象类是可以被实例化的 C)派生类不能成为抽象类 D)抽象类的子类必须实现父类中的纯虚函数 (3)下面程序的结果是 #include class test private: int num; public: test(); int getint()return num; test(); test : test() num =0; test:test() coutDestructor is active test x3; coutExiting main Destructor is active Destructor is active Destructor is active B)Exiting main Destructor is active Destructor is active C)Exiting main Destructor is active D)Exiting main (4)如果表达式-x+y中,-是作为成员函数重载的, +是作为成员函数重载的,那么该表达式还可为 A)y.operator+(x.operator-(0) B)y.operator+(x.operator-() C)y.operator+(operator-(x,0) D)operator+(x.operator-() (5)以下语句不能够用于翻开C根目录下文件test.txt的语句是 A)ifstream fin; fin.open(C:test.txt); B)ifstream fin(C:test.txt); C)A)和B) D)ifstream fin; fin(C:test.txt); (6)以下哪个基类中的成员函数表示纯虚函数? A)virtual void vf (int) B)void vf (int)=0 C)virtual void vf(=0) D)virtual void yf(int) (7)下面程序输出的结果是 #include void main() int i; int a33=1,2,3,4,5,6,7,8,9; for(i=0;i3;i+) cout aii ; A)1 5 9 B)7 5 3 C)3 5 7 D)5 9 1 (8)派生类继承基类的方式有 A)public B)private C)protected D)以上都对 (9)以下程序的运行结果为 #include class Location protected: int X, Y; public: void SetX(int myx)X=myx; void SetY(int myy)Y=myy; void showxy()cout X= X Y= Y private: int H, W; public: void SetH(int myh)H=myh; void SetW(int myw)W=myw; void show() cout X= X Y= Y H= H W= W endl; void main() Rectangle r1; r1.SetX (3); r1.SetY (5); r1.SetH (4); r1.SetW (6); r1.showxy(); r1.show(); A)X=3 Y=5 X=3 Y=5 H=4 W=6 B)X=3 Y=5 X=3 Y=5 H=3 W=6 C)X=3 Y=5 X=3 Y=4 H=4 W=6 D)X=3 Y=5 X=3 Y=3 H=4 W=6 (10)有以下程序 #include void ss(char *s,char t) while(*s) if(*s=t)*s=t-a+A; s+; void main() char str1100=abcddfefdbd,c=d; ss(str1,c); cout str1; 程序运行后的输出结果是 A)ABCDDEFEDBD B)abcDDfefDbD C)abcAAfefAbA D)Abcddfefdb 1)有以下程序 #include void main() int a=5,b=0,c=0; if(a=b+c)cout * ?$?以下选项表达正确的选项是 A)有语法错不能通过编译 B)可以通过编译但不能通过连接 C)输出* D)输出$ (2)各变量的定义如下 int i=8,k,a,b; unsigned long w=5; double x=1.42,y=5.2; 那么以下符合C+语言语法的表达式是 A)a+=a-=(b=4)*(a=3)
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号