选择题 有如下类声明:
class MyBASE {
int k;
public:
void set(int n) {k=n;}
int get()const {return k; }
};
class MyDERIVED: protected MyBASE {
Protected:
int j;
public:
void set(int m,int n){MyBASE:: set(m);j=n;}
int get () const {return MyBASE:: get ()+j; }
};
则类MyDERIVED 中保护的数据成员和成员函数的个数是______ 。
选择题 给出下面程序输出结果______。
#include<iostream.h>void main()
{int *p1;
int **p2=p1;
int b=20;
p1=b;
cout<<**p2<<endl;
}
选择题 在C++语言中,封装是借助于什么达到的?______
选择题 有如下程序:
#include<iostream>
using namespace std;
class Point{
public:
Point(int xx=0,int yy=0):x(xx),y(yy){}
void SetX(int xx){x=xx;}
void SetY(int yy){y=yy;}
private:
int x,y;
};
class Circle:Point{
public:
Circle(int r):radius(r){}
int GetRadius(){return radius;}
private:
void SetRadius(int r){radius=r;}
int radius;
};
int main(){
Circle c1(5);
c1.SetX(1); //①
c1.SetY(2); //②
c1.SetRadius(10); //③
cout<<c1.GetRadius(); //④
return 0;
}
在标注号码的语句行中不存在语法错误的是______。
选择题 有如下程序:
#include<iostream>
using namespace std;
class Instrument {
public:
virtual void Display()=0;
};
class Piano: public Instrument {
public:
void Display() {/*函数体略*/}
};
int main() {
Instrument s;
Instrument*P=0;
//…;
return 0;
}
下列叙述中正确的是______。
选择题 下面是一个模板声明的开始部分:
templute<typename T>double
由此可知______。
选择题 下列重载函数中,正确的是 。
选择题 以下程序的结果是 。
#include<iostream.h>
void main()
{char * p='abcdefgh',*r;
long *q;
q=(long*)P;
q++;
r=(char*)q;
cout<<r<<endl;
选择题 有如下程序:
#qnclude<iostream>
#include<iomanip>
using namespace std;
class CSum
{ int x,y;
public:
CSum(int x0,int y0):x(x0),y(y0){}
friend ostream operator<<(ostreamos,const CSumxa)
{ os<<setw(5)<<Ka.k+xa.y;
return os;
}
};
int main(){
CSum y(3.5};
cout<<setfill('*')<<8
cout<<y;
return0;
}
执行上面程序的输出是
选择题 下面程序的运行结果是 。
#include<iostream.h>
void main()
{
int i=1;
while(i<=8)
if(++i%3!=2)continue;
else cout<<i;
}
选择题 一个满二叉树其深度为4,则其叶子节点的个数为 。
选择题 对长度为n的线性表进行顺序查找,在最坏情况下所需要的比较次数为______。
选择题 有如下两个类定义:
class XX{
private:
double x1;
protected:
double x2;
public:
double x3;
};
class YY:protected XX{
private:
double y1;
protected:
double y2;
public:
double y3;
};
在类YY中保护成员变量的个数是______。
选择题 若一个函数的原型为“int * Xfun1(int x.int y, char z);”,则该函数的返回值类型为______。
选择题 若要重载+、=、<<、=和[]运算符,则必须作为类成员重载的运算符是
选择题 while和do-while循环的主要区别是______
选择题 下列关于成员访问权限的描述中,不正确的是______。
选择题 数据库技术的根本目标是______。
选择题 有如下程序:
#include<iostream>
using namespqce std;
class TestClass
{
private;
char c;
public;
TestClass(char n):c(n){}
~TestClass()
{
cout<<c;
}
};
class TestClass1:public TestClass
{
private:
char c;
public:
TestClass1(char n):TestClass(n+1),c(n){}
~TestClass1()
{
cout<<c;
}
};
int main()
{
TestClass1 obj('x');
return 0;
}
执行上面的程序将输出______。
选择题 检查软件产品是否符合需求定义的过程称为______。