发布时间 : 星期一 文章二级c++笔试历年真题更新完毕开始阅读d08c878cb9d528ea81c779ca
int main(){
XCF d1(5),d2(d1); XCF *pd=new XCF(8); cout<
运行时的输出结果是______。
A、1215588 B、1218855 C、12185 D、128512
25. 有如下程序段: int i=4;int j=1; int main() { int i=8,j=i; cout<
运行时的输出结果是______。
A、44 B、41 C、88 D、81
26. 有如下程序: #include
Pair(int i,int j):m(i),n(j){}
bool operator >(Pair p)const; //须在类体外给出定义 };
int main(){
Pair p1(3,4),p2(4,3),p3(4,5);
cout<<(p1>p2)<<(p2>p1)<<(p2>p3)<<(p3>p2); return 0; }
运算符函数operator>的功能是比较两个Pair对象的大小,当左边对象大时,返回true,否则返回false。比较规则是首先比较两对象的m成员,m大者为大;当m相等时比较n,n大者为大。程序输出0101,下列对运算符重载函数的正确定义是______。
A、bool Pair::operator >(Pair p)const
{if (m!=p.m) return m>p.m; return n>p.n;} B、bool Pair::operator >(Pair p)
{if(m!>p.m) return m>p.m;return n>p.n;} C、bool Pair::operator >(Pair p)const
{if(m>p.m) return true;return n>p.n;} D、bool Pair::operator >(Pair p)
{if(m>p.m) return true;return n>p.n;}
27. 已知函数fun的原型为
int fun (int,int,int);
下列重载函数原型中错误的是______。
A、char fun(int,int); B、double fun(int,int,double); C、int fun(int,clar*); D、float fun(int,int,int);
28. 有如下程序: #include
virtual void f(){cout<<1;} void g(){cout<<2;} };
class B:public A{ public:
virtual void f(){cout<<3;} void g(){cout<<4;} };
void show(A &a){a.f(); a.g();} int main(){ B b; show(b); return 0; }
运行时的输出结果是______。
A、12 B、34 C、14 D、32
29. 对C++编译器区分重载函数无任何意义的信息是______。
A、参数类型 B、参数个数 C、返回值类型 D、常成员函数关键字const
30. 通过派生类的对象可直接访问其______。
A、公有继承基类的公有成员 B、公有继承基类的私有成员 C、私有继承基类的公有成员 D、私有继承基类的私有成员
31. 建立一个类对象时,系统自动调用______。
A、析构函数 B、构造函数 C、静态函数 D、友元函数
32. 有如下程序: #include
void setK(int k){ this->k=k;} public:
void setN(int n){ this->n=n;} };
class BB:public AA{/*类体略*/};
int main(){
BB x; x.n=1; //1 x.setN(2); //2 x.k=3; //3 x.setK(4); //4 return 0; }
在标注号码的四条语句中正确的是______。
A、1 B、2 C、3 D、4
33. 已知类MyClass声明如下: class MyClass{ int n; public:
MyClass(int k):n(k){}
int getValue()const{return n;} };
在下列数组定义中正确的是______。
A、MyClass x1[2]; B、MyClass x2[2]={new MyClass(1),new MyClass(2)}; C、MyClass *x3[2]; D、MyClass *x4[2]={MyClass(1),MyClass(2)};
34. 有如下程序段: int i=5;
while (int i=0){ cout<<'*'; i--; } 运行时输出\的个数是______。
A、0 B、1 C、5 D、无穷
35. 下列关于函数模板的描述中,错误的是______。
A、从模板实参表和从模板函数实参表获得信息矛盾时,以模板实参的信息为准 B、对于常规参数所对应的模板实参,任何情况下都不能省略
C、虚拟类型参数没有出现在模板函数的形参表中时,不能省略模板实参 D、模板参数表不能为空
36. 符合结构化原则的三种基本控制结构是:选择结构、循环结构和______。
37. 假设用一个长度为50的数组(数组元素的下标从0到49)作为栈的存储空间,栈底指针bottom指向栈底元素,栈顶指针top指向栈顶元素,如果bottom=49,top=30(数组下标),则栈中具有______个元素。 38. 在E-R图中,图形包括矩形框、菱形框、椭圆框。其中表示实体联系的是______框。 39. 软件测试可分为白盒测试和黑盒测试。基本路径测试属于______测试。 40. 数据库系统的核心是______。 41. 有如下程序段: char c[20]=\c[4]=0; cout< 执行这个程序段的输出是______。 42. 下面的函数利用递归实现了求1+2+3…..+n的功能: int sum(int n){ if( n==0 ) return 0; else return n+sum(n-1); } 在执行sum(10)的过程中,递归调用sum函数的次数是______。 43. 有如下程序: #include Monitor(char t):type(t){} void Print() const {cout<<\private: char type; }; class Computer{ public: Computer(int i,char c):______{} void Print() const {cout<<\private: int id; Monitor mon; }; int main(){ const Computer myComputer(101,'B'); myComputer.Print(); return 0; } 请将程序补充完整,使程序在运行时输出: The computer is 101 The type of monitor is B 44. 有如下程序段: for (int i=1;i<=50;i++){ if(i%3!=0) continue; else if(i%5!=0) continue; cout< 执行这个程序段的输出是______。 45. 补充完整下面的模板定义: