为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

C++__复习题(武汉大学)

2013-07-04 30页 doc 405KB 42阅读

用户头像

is_985623

暂无简介

举报
C++__复习题(武汉大学)1 8 9 11 12 13 15!16 20 21 23 24 25 26 28 29 31 37 (三道没号的) 27 29 30 31 32 1 2 6 7 无号41 44 45 4 6 7 8 10 12 20 37 无号 30 31 33 1) 下列关于对象概念的描述中,(a)是错误的。 A. 对象就是C语言中的结构变量 B. 对象代表着正在创建的系统中的一个实体 C. 对象是一个状态和操作(或方法)的封装体 D. 对象之间的信息传递是通过消息进行的 2) #include #...
C++__复习题(武汉大学)
1 8 9 11 12 13 15!16 20 21 23 24 25 26 28 29 31 37 (三道没号的) 27 29 30 31 32 1 2 6 7 无号41 44 45 4 6 7 8 10 12 20 37 无号 30 31 33 1) 下列关于对象概念的描述中,(a)是错误的。 A. 对象就是C语言中的结构变量 B. 对象代表着正在创建的系统中的一个实体 C. 对象是一个状态和操作(或方法)的封装体 D. 对象之间的信息传递是通过消息进行的 2) #include #include void main() { cout.fill('*'); cout.width(10); cout<<"123.45"< #define SQR(x) x*x void main() { int a=10,k=2,m=1; a/=SQR(k+m); cout< { //This is my first program cout<<"My first program in C++"; } 这段C++程序的输出是(d)。 a) My first program in C++ b) This is my first program c) My first Program in C d) None of the above 8) #include class example { private: static int num; public: example(){num++;cout<内容
,然而可以用myptr2改变它指向的整数的内容 C.不能用myptr2改变常整数的内容,然而可以用myptr1改变它指向的整数的内容 10) 在C++中,一个函数为void f(int=1,char='a'),另一个函数为void f(int),则它们(b)。 a) 不能在同一程序中定义 b) 可以在同一程序中定义并可重载 c) 可以在同一程序中定义,但不可重载 d) 以上说法都不正确 11) C++ 基类中的private成员通过(d)类型的继承,可以被派生类访问。 a) public b) protected c) private d) 任何类型的继承都不能使得派生类可以访问基类的private成员 12)下列概念()体现了面向对象的多态性。(b) a) 虚基类 b) 虚函数 c) 对象容器 d) 封装 13) #include class One { public: void display(){cout<<"1"<<"";} }; class Two:public One { public: void display(){cout<<"2"<<"";} }; void main() { One first; Two second; first.display(); second.display(); One *p=&first; p->display(); p=&second; p->display(); } 在C++中,以上程序的运行结果为(c)。 a) 1 1 1 2 b) 1 2 1 2 c) 1 2 1 1 d) 2 1 1 2 14} 15) 对于C++类 class date { private: int day,month,year; public: void setdate(int,int,int); print(); }; 下列描述是正确的(d)。(选择两项) a) setdate()函数内参数没有写变量名,因而它是错误的; b) year是私有的,print()是公有的,setdate()可以访问day,而print()不能访问day c) setdate()可以访问day,而print()不能访问day d) setdate()可以访问day,而print()也可以访问day 16) 在C++中,可以重载的运算符有(d)。 a) sizeof() b) :: c) .* d) ++ 17) #include class date { private: int day ,month,year ; public: date(){} date(int x,int y,int z){day=x;month=y,year=z;} void set(){day=1;month=10;year=2002;} void display(){cout< class A { public: A(){cout<<"A construct";} }; class B:public A { public: B():A(){cout<<"B construct"< class X { private: int num; public: X(int intx){num=intx;} X(X &Y) { num=++Y.num; } void disp(){cout< int &func(int &num) { num++; return num; } void main() { int n1,n2=5; n1=func(n2); cout< class A { public: A(){} ~A(){cout<<"A destroy";} }; class B:public A { public: B():A(){} ~B(){cout<<"B destroy";} }; void main(){B obj;} 上面的C++程序运行的结果是(a)。 a) B destroy A destroy b) A destroy B destroy c) A destroy d) B destroy 29) 如果基类A 和A 的派生类B中都有成员函数func(); 要在派生类的func()中调用同名的基类的func()成员函数,下列(b)操作下正确的。 a) func(); b) A::func(); c) B::func(); d) A.func(); 30) #include class A { public: virtual~A(){cout<<"A"<<" ";} }; class B:public A { ~B(){cout<<"B"<<" ";} }; void main() { A*pObj=new B; delete pObj; } 上面的C++程序的运行结果是(d). a) A b) B c) A B d) B A 31) 在C++中,(b)一定不能创建类的对象和实例. a) 虚基类 b) 抽象类 c) 基类 d) 派生类 32) 读下面C++程序: #include class line { public: int color; }; int startx; class box { private: int upx,upy; int lowx,lowy; public: int color; int same_color(line a,box b); void set_color(int c) { color = c; } void define_line(int x,int y) { startx = x; } }; int (在此添入答案) same_color(line a,box b) { if(a.color==b.color) return 1; return 0; } 在括号中添入(b),该程序才能正常运行. a) line:: b) box:: c) line-> d) box-> 33) 在c++中,定义了以下的一个类 class example { Private: int data; Public: int set(int param); }; 下列操作(d)是正确的 a) example object; object.data=10; b) example object; data=object.set(10); c) example object; object.data=object.set(10) d) example object; 34)读下面C++程序: #include class vehicle { protected: int wheels; public: vehicle(int in_wheels=4){wheels=in_wheels;} int get_wheels(){ return wheels;} }; void main() { vehicle unicyclel; vehicle unicycle2(3); cout<<"The unickele1 has"<         class A         {               int num;          public:              A(int i){num=i;}              A(A &a){num=a. num++;}              void print(){cout<模板
的描述,错误的是(A)   A)函数模板和类模板的参数可以是任意的数据类型   B)类模板不能直接使用,必须先实例化为相应的模板类.然后定义了模板类的对象后才能使用   C)函数模板不能直接使用,需要实例化为模板函数后才能使用   D)类模板的成员函数都是模板函数 (32)语句ofstream f(”SALARY. DAT",ios::app iios::binary);的功能是建立流对象f,试图打开文件SAL:aRY. D AT并与之连接,并且(A)   A)若文件存在,将文件写指针定位于文件尾;若文件不存在,建立一个新文件   B)若文件存在,将其置为空文件;若文件不存在,打开失败   C)若文件存在,将文件写指针定位于文件首;若文件不存在,建立一个新文件   D)若文件存在,打开失败;若文件不存在,建立一个新文件 (33)下面程序的运行结果是(C)        #include        void main()        {              int num=1;              int &ref=num:              ref=ref+2;              cout< int i=0; class A { public: A(){i++;} }; void main() { A a,b[3],*c; c=b; cout< class example { private: static int num; public: example(){num++;cout< class A {public: A(){cout<<"A construct";} ~A(){cout<<"A constroy";} }; class B:public A { public: B():A(){cout<<"B construct";} ~B():A()RAVSKYUP{cout<<"B destroy";} }; void main(){"B destroy";} 上面的C++程序运行的结果是()。(选择一项) a) B construct A construct B destroy A destroy b) A construct B construct A destroy B destroy c) A construct B construct B destroy A destroy d) B construct A construct A construct B construct 43 #include class sample { private: int a,b; public: sample(int x ){a=x;b=1;cout<思想
是( )。(选两项) a) 真实反映用户的实际需求 b) 将现实世界的一些抽象为实体或对象 c) 将现实世界细分为一个个过程化实现 d) 将软件组织成为对象的集合,将数据结构和行为结合在一起 1、 1. 在 ( ) 情况下适宜采用 inline 定义内联函数。  A. 函数体含有循环语句  B. 函数体含有递归语句  C. 函数代码少、频繁调用  D. 函数代码多、不常调用  2. 在类中说明的成员可以使用关键字 ( ) 进行修饰。  A. private B. extern  C. auto D. register  3. 如果类 A 被说明成类 B 的友元,则 ( ) 。  A. 类 A 的成员即类 B 的成员  B. 类 B 的成员即类 A 的成员  C. 类 A 的成员函数不得访问类 B 的成员  D. 类 B 不一定是类 A 的友元  4. 定义析构函数时,应该注意 ( ) 。  A. 其名与类名完全相同 B. 返回类型是 void 类型  C. 无形参,也不可重载 D. 函数体中必须有 delete 语句  5. 在类中声明转换函数时不能指定 ( ) 。  A. 参数 B. 访问权限  C. 操作 D. 标识符  6. 在派生类中重新定义虚函数时必须在 ( ) 方面与基类保持一致。  A. 参数类型 B. 参数名字  C. 操作内容 D. 赋值  7. 在公有继承的情况下,基类成员在派生类中的访问权限 ( ) 。  A. 受限制 B. 保持不变  C. 受保护 D. 不受保护  8. 通过 ( ) 调用虚函数时,采用动态束定。  A. 对象指针 B. 对象名  C. 成员名限定 D. 派生类名  9. 在 int a=3,*p=&a; 中, *p 的值是 ( ) 。  A. 变量 a 的地址值 B. 无意义  C. 变量 p 的地址值 D. 3  10.C++ 类体系中,不能被派生类继承的有 ( ) 。  A. 转换函数 B. 构造函数  C. 虚函数 D. 静态成员函数  11. 假定一个类的构造函数为 A(int aa,int bb){a=aa++;b=a*bb++;} ,则执行 Ax(4,5); 语句后, x.a 和 x.b 的值分别为 ( ) 。  A. 4 和 5 B. 5 和 4  C. 4 和 20 D. 20 和 5  12. 假定 AB 为一个类,则执行 AB x ;语句时将自动调用该类的 ( ) 。  A. 有参构造函数 B. 无参构造函数  C. 拷贝构造函数 D. 赋值构造函数  13.C++ 语言建立类族是通过 ( ) 。  A. 类的嵌套 B. 类的继承  C. 虚函数 D. 抽象类  14. 执行语句序列 ofstream outf( “ SALARY.DAT ” ) ; if(...)cout<< “成功”; else cout<< “失败”;后,如文件打开成功,显示”成功”,否则显示”失败” . 由此可知,上面 if 语句的条件表达式是 ( ) 。  A. !outf 或者 outf.fail()  B.!outf 或者 outf.good()  C. outf 或者 outf.fail()  D. outf 或者 outf.good()  15. 静态成员函数不能说明为 ( ) 。  A. 整型函数 B. 浮点函数  C. 虚函数 D. 字符型函数  16. 在 C++ 中,数据封装要解决的问题是 ( ) 。  A. 数据化排列 B. 数据高速转换  C. 避免数据丢失 D. 保证数据完整性  17. 在 C++ 中有以下 4 条语句: static int hot=200;int &rad=hot;hot=hot+100;cout< #define SQR(x) x*x void main() { int a=10,k=2,m=1; a/=SQR(k+m); cout< class One { public: void display(){cout<<"1"<<"";} }; class Two:public One { public: void display(){cout<<"2"<<"";} }; void main() { One first; Two second; first.display(); second.display(); One *p=&first; p->display(); p=&second; p->display(); } 在C++中,以上程序的运行结果为(c)。 a) 1 1 1 2 b) 1 2 1 2 c) 1 2 1 1 d) 2 1 1 2 16) 在C++中,可以重载的运算符有(d)。 a) sizeof() b) :: c) .* d) ++ 17) #include class date { private: int day ,month,year ; public: date(){} date(int x,int y,int z){day=x;month=y,year=z;} void set(){day=1;month=10;year=2002;} void display(){cout< class X { private: int num; public: X(int intx){num=intx;} X(X &Y) { num=++Y.num; } void disp(){cout< class vehicle { protected: int wheels; public: vehicle(int in_wheels=4){wheels=in_wheels;} int get_wheels(){ return wheels;} }; void main() { vehicle unicyclel; vehicle unicycle2(3); cout<<"The unickele1 has"<        void main()        {              int num=1;              int &ref=num:              ref=ref+2;              cout< int i=0; class A { public: A(){i++;} }; void main() { A a,b[3],*c; c=b; cout<规定
函数说明符必须用原型 D.引进了类和对象的概念 ¤下列关于运算符重载的叙述中,正确的是(B )。 A.通过运算符重载,可以定义新的运算符 B.有的运算符只
/
本文档为【C++__复习题(武汉大学)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
相关资料
热门搜索
你可能还喜欢
最新资料 资料动态 专题动态

历史搜索

    清空历史搜索