发布时间 : 星期四 文章二级c++笔试历年真题更新完毕开始阅读d08c878cb9d528ea81c779ca
A、const int a; B、const int a=10; C、const int *point=0; D、const int *point=new int(10);
24. 在下列原型所示的C++函数中,按\传值\方式传递参数的是______。
A、Void f1(int x); B、Void f2(int *x); C、Void f3(const int *x); D、Void f4(int &x);
25. 建立一个有成员对象的派生类对象时,各构造函数体的执行次序为______。
A、派生类、成员对象类、基类 B、成员对象类、基类、派生类 C、基类、成员对象类、派生类 D、基类、派生类、成员对象类
26. 下列模板声明中,有语法错误的是______。
A、template
B、template
27. 下列关于运算符重载的叙述中,错误的是______。
A、有的运算符可以作为非成员函数重载 B、所有的运算符都可以通过重载而被赋予新的含义
C、不得为重载的运算符函数的参数设置默认值 D、有的运算符只能作为成员函数重载
28. 下列运算符函数中,肯定不属于类Value的成员函数的是______。
A、Value operator+(Value); B、Value operator-(Value,Value); C、Value operator*(int); D、Value operator/(Value);
29. 在一个抽象类中,一定包含有______。
A、虚函数 B、纯虚函数 C、模板函数 D、重载函数
30. 如果表达式a>=b中的\是作为非成员函数重载的运算符,则可以等效地表示为______。
A、a.operator>=(b) B、b.operator>=(a) C、operator>=(a,b) D、operator>=(b,a)
31. 有如下程序: #include
MyClass(int i=0){cout<<1;}
MyClass(const MyClass&x){cout<<2;}
MyClass& operator =(const MyClass&x){cout<<3;return *this;} ~MyClass(){cout<<4;} };
int main(){
MyClass obj1(1),obj2(2),obj3(obj1); return 0; }
运行时的输出结果是______。
A、112444 B、11114444 C、121444 D、11314444
32. 当使用ofstream流类定义一个流对象并打开一个磁盘文件时,文件的默认打开方式为______。
A、ios_base::in B、ios_base::binary C、ios_base::in | ios_base::out D、ios_base::out
33. 有如下程序:
#include
for(int i=0;i<6;i+=3){ sum=i;
for(int j=i;j<6;j++) sum+=j; }
cout< 运行时的输出结果是______。 A、3 B、10 C、12 D、15 34. 定义派生类时,若不使用关键字显式地规定采用何种继承方式,则默认方式为______。 A、私有继承 B、非私有继承 C、保护继承 D、公有继承 35. 若已经声明了函数原型\,则下列重载函数声明中正确的是______。 A、void fun(int a=90,double b=0.0); B、int fun(int a,double B); C、void fun(double a,int B); D、bool fun(int a,double b=0.0); 36. 数据库设计包括概念设计、______和物理设计。 37. 软件工程三要素包括方法、工具和过程,其中,______支持软件开发的各个环节的控制和管理。 38. 在二维表中,元组的______不能再分成更小的数据项。 39. 按照软件测试的一般步骤,集成测试应在______测试之后进行。 40. 对下列二叉树进行中序遍历的结果是______。 41. 有如下程序: #include pumpkin(){++count;} ~pumpkin(){--count;} static void total_count(){ cout< static int count; }; int pumpkin::count=0; int main(){ pumpkin p1[10]; pumpkin::total_count(); return 0; } 这个程序的输出结果是______。 42. 有如下类定义,请将Sample类的拷贝构造函数补充完整。 class Sample{ public: Sample(){} ~Sample(){if(p) delete p;} Sample(const Sample& s){ ______ } void SetData(int data) {p=new int(data);} private: int *p; }; 43. 请在下列程序中的空格处填写正确的语句: class Sample{ public: Sample(){} ~Sample(){} void SetDate(int data) {//将Sample类成员变量date设置成形参的值 ______ } private:int data; }; 44. 有如下递归函数: int Fun(int n){ if(n<=1) return 1; ______ } 请补充完整,使得函数Fun能够正确计算形参n的阶乘。 45. 有如下程序: #include class Wages{ //\工资\类 double base; //基本工资 double bonus; //奖金 double tax; //税金 public: Wages(double CBase,double CBonus,double CTax): base(CBase),bonus(CBonus),tax(CTax){} double getPay()const; //返回应付工资额 Wages operator+(Wages w)const; //重载加法 }; double Wages::getPay()const{return base+bonus-tax;} Wages Wages::operator+(Wages w)const{ return Wages(base+w.base, bonus+w.bonus,tax+w.tax); } int main(){ Wages w1(2000,500,100),w2(5000,1000,300); cout<<(w1+w2).getPay()< 程序的输出结果是______。 46. 已知数组a中有n个元素,下列语句将数组a中从下标x1开始的k个元素移动到从下标x2开始的k个元素中,其中0<=x1 47. 重载加法运算符\,其函数名是______。 48. 当使用关键字______作为函数返回类型时,该函数不返回任何值。 49. 有如下程序: #include int fun1(int x) {return ++x;} int fun2(int &x) {return ++x;} int main(){ int x=1,y=2; y=fun1(fun2(x)); cout< 程序的输出结果是______。 50. 有如下程序: #include