为了正常的体验网站,请在浏览器设置里面开启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< 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<        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,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索