当前位置:首页 > 全国2010年10月自考C++ 程序设计试题
全国2010年10月自学考试C++程序设计试题
课程代码:04737
一、单项选择题(本大题共20小题,每小题1分,共20分) 1.C++中注释“∥”的有效范围是( 从“∥”开始到行尾 )
2.假定MyClass为一个类,则该类的复制构造函数的声明语句为( .MyClass(MyClass &x) ) 4.用于标识十进制常量的前缀或后缀是( .无前后缀 )
5.设int x=56;int r=x;若cout <<&x;显示0012FF7A,则cout <<&r;输出值为( 未知 ) 6. A.dec B.oct C.hex
7.C++中是否允许在类结构中定义函数(允许 )
8.设函数void subone(int &)将形参减1,如有整型变量int k=10,则执行subone(k);后,k的值为( 9 ) 9.对函数int max(int a,int b=0,int c=0,int d=0,int e=0);下列调用方式正确的是( a ) A.int m=max(10,11,12,13,14); B.int m=max(10,,12,13,14); C.int m=max(10,1l,,13,14); D.int m=max(10,11,12,,14); 10.类MyClass的定义如下: class MyClass { public: MyClass(){}
MyClass(int i){value=new int(i);} int * value;
};
若要对value赋值,则下面语句正确的是( d ) A.MyClass my;my.value=10;
B.MyClass my;*my.value=10;
C.MyClass my;my.*value=10; D.MyClass my(10); 11.包含哪种语句的函数不能声明为内联函数( switch for )
12.声明函数模板的关键字是( template )
13.对于类中的成员,使用public修饰,表明该成员的访问权限是(公有的 ) 14.一个类中不允许一个无参数构造函数和一个全部都是默认参数的构造函数共存 15.析构函数的参数个数为( .0个 )
16.非静态成员函数都会有一个隐含指针,它是( this指针 ) 17.下列访问公有静态成员的方式,有A.类名::静态成员名 B.对象名.静态成员名 C.对象指针->静态成员名 18.声明友元使用关键字( friend )
19.派生类继承了基类的( 所有成员 )
20.基类private成员,通过public派生,其在派生类中为( 不可访问 ) 二、填空题(本大题共20小题,每小题1分,共20分)
请在每小题的空格中填上正确答案。错填、不填均无分。 21.执行下列代码
double pi=3.141592;
cout< 程序的输出结果是__3_______。 22.要使用STL库提供的对数组进行升幂排序算法,在源程序中需要包含的头文件是___ algorithm ______。 23.C++语言中动态回收内存的关键字是___delete[]______。 24.执行下列代码 1 int b=100; cout<<”Oct:”< 程序的输出结果是__144_______。 25.C++语言中用于定义一个类的关键字是___class______。 26.为了使用C++语言标准程序库提供的string类,在程序中必须使用的文件包含命令是__#include 29.将指向对象的指针作为函数参数,形参是对象指针,实参是对象的__地址值 _______。 30.C++函数有库函数(标准函数)和__自定义函数 _______两类。 31.C++中通过___构造函数______对类的对象进行初始化。 32.UML中实例连接反映对象之间的静态关系,消息连接描述对象之间的__动态_______关系。 33.若将一个对象说明为常对象,则通过该对象只能调用它的_ const________成员函数,不能调用其它成员函数。 34.静态成员函数是_ _类_______的成员,不是对象的成员。 35.私有继承时,在派生类中基类的protected权限变为___private或私有______。 36.若使用一个表达式的含义能解释为访问多个基类中的成员,则这种对基类成员的访问就是不确定的,称这种访问具有_二义性________。 37.如果在类模板的定义中有一个静态数据成员,则在程序运行中会产生____一个或多个_____静态变量。 38.vector类中用于获取向量可以容纳最多对象的个数的方法是__max_size()_______。 39.C++用于运算符重载的关键字是operator___。 40.含有_____.纯虚函数______的类称为抽象类,它只能作为基类来使用。 三、改错题(本大题共5小题,每小题4分,共20分) 下面的每题中有一处错误,请用下横线标出错误所在行并给出修改意见 41. #include < iostream, h > class testl { private : int x; public: testl ( ) { x = 2 ; } void set(int a){x =a;} void get( ) { cout << x << endl; } }; class test2{ private: int x; public : test2 ( ) { x = 3 ; } void set( int a) { x = a; } void get( ) { cout << x << endl; } }; class test: public testl, public test2 { private : int x; public:void set( int a) { x=a; } void gettest( ) {cout << x << endl; } }; void main( ) { test a; a. get( ); } 42. #include < iostream, h > 2 class test { private : int x, y; public : void testl ( int a, int b) { x = a ; y = b;} int max( ); }; int test:max( ) {if(x>y) return x;else return y;} void main( ){ test a; a. testl ( 1,3); cout << a. max ( ) << endl; } 43. #include < iostream, h > void main() { int x =5; const int * const p = &x; * p =88; cout << * p << endl; } 44. #include < iostream, h > class point { private : float x, y ; public : f( float a, float b) { x = a ; y = b ; } f( ) {x=O;y=O;} void getx( ) { cout < < x < < endl; } void gety ( ) { cout < < y < < endl ; } } class pointl } private : float x, y ; public : f( float a, float b) { x = a; y = b ; } f( ){x=l;y=l;} void getx( ) {cout < main( ) I point a; a.f(); a. getx( ) ;a. gety ( ); } 45. #include < iostream, h > void main( ) { string strl (\ cout << strl << endl; } 四、完成程序题(本大题共5小题,每题4分,共20分) 3 46.在下面程序的下划线处填上正确的数据类型,保证程序具有如下输出结果: 0 17 17,17,17 源程序如下: #include < iostream > using namespace std; class base { public : ______________num; base ( ) { } }; int base::hum = 0; void main( ) { cout << base::num << endl; _________________* p=&base : :num; *p=17; cout << base::num << end1; base a,b; cout << * p<<\47.在下面横线处填上正确的内容,完成类的定义。 class Base { int x; static const int b; public: Base( int, int); const int &a; }; ______________b =15; Base::Base(int i,int j): ___________{ } 48.完成下面程序中的show函数的定义,使其运行结果如下: In base In derived 程序清单如下: #include using namespace std; class base { pubhc : virtual void print( ) { cout << \ } 4 }; class derived: public base { public : void print( ) { cout << \}; void show(base * pb,void (base:: * pf) ( ) ) { _________ } void main( ) { base b; derived d ;
共分享92篇相关文档