为了正常的体验网站,请在浏览器设置里面开启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"<分析
下面的C++代码段: class Employee { private: int a; protected: int b; public: int c; }; class Director:public Employee{}; 在Main()中,下列(c)操作是正确的。 a) Employee obj; obj.b=1; b) Director boj; obj.b=10; c) Employee obj; obj.c=3; d) Director obj; obj.a=20; 4) #include #define SQR(x) x*x void main() { int a=10,k=2,m=1; a/=SQR(k+m); cout<
了: #define sqr(x) ( (x) * (x) )本文出自 51CTO.COM技术博客 5) 在C++语言中,下列语句中,正确的是(d)。 a) void main() { 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< #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<
/
本文档为【C++__复习题(武汉大学)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
相关资料
热门搜索
你可能还喜欢
最新资料 资料动态 专题动态

历史搜索

    清空历史搜索