填空题有如下两个类声明
class AA {
public:
int m;
};
class BB: protected AA{
int n;
};
在类BB中,数据成员m的访问属性是__【12】__,数据成员n的访问属性是__【13】__。
填空题以下程序的执行结果是{{U}} {{U}} {{/U}} {{/U}}。
#include<iostream. h>
class Sample
{
public:
int x:
int y;
void disp()
{
cout<<"x="<<x<<",y="<<y<<end1;
}
};
void main()
{
int Sample:: ** pc;
Sample s;
pc=
s.*pc=10;
pc:=
s.*pc=20;
s.disp();
}
填空题静态联编所支持的多态性称为编译时的多态性,动态联编所支持的多态性则称为运行时的多态性,动态多态性由 【4】 来支持。
填空题如果一个数组中的每个元素都是同一类的对象,则该数组被称为 【9】 。
填空题假定输入的10个整数为:32,64,53,87,54,32,98,56,98,83。那么下列程序的运行结果是 【6】 。 #include <iostream> using namespace std; int main() int a,b,C,X; a = b = C = 0; for(int i = 0;i<10;i++) cin>>x; switch(x%3) case 0 :a+=x; break; case 1 :b+=x; break; case 2 : C+=x; break; cout<<a<<","<<b<<","<<C<<end1; return 0;
填空题按数据流的类型,结构化设计方法有两种设计策略,它们是{{U}} 【4】 {{/U}}和事务分析设计。
填空题有以下程序:
#include <iostream>
using namespace std;
int main()
{
int m[5],n[5],*px,*py,k;
px=m;
py=n;
for(k=1;k<4;k++)
{
*px=k;
*py=2*k;
cout<<m[k-1]<<n[k-1];
px++;py++;
}
cout<<end1;
return 0;
}
运行后的输出结果为{{U}} 【8】 {{/U}}。
填空题当循环队列非空且队尾指针等于队头指针时,说明循环队列已满,不能进行入队运算。这种情况称为 【2】 。
填空题如果一个模板声明时有类型形参表,则多个参数之间必须使用_______隔开,每个参数都必须重复使用关键字______。
填空题假定用户没有给一个名为MyClass的类定义析构函数,则系统为其定义的默认析构函数首部形式为
________
。
填空题下面程序的输出结果为{{U}} {{U}} {{/U}} {{/U}}。
#include <iostream>
using namespace std;
void initialize(int printNo, int state=0);
void initialize(iht printNo= 1,int state);
int main()
{
initialize();
return 0;
}
void initialize(int printNo, int state)
{
cout<<printNo<<","<<state<<end1;
}
填空题以下函数模板max()的功能是:返回数组a中最大元素的值。请将横线处缺失部分补充完整。
template<typename T> T max(T a[ ],int n)
{
T m=a[0];
for(int i=1;i<n;i++)
if(a[i]>m) ______;
return m;
}
填空题设有下定义的语句: int a[3][2]=10,20,30,40,50,60; int b[3][2]=10,20,30,40,50,60; 则a[1][1]*b[2][1]= 【10】 。
填空题已知下列程序的输出结果是42,请将横线处缺失的部分补充完整。
#include<iostream>
using namespace std;
class TestClass{
int value;
public:
TestClass():value(0){};
void setValue(int value)
{______=value;}//给TestClass的数据成员value赋值
void print(){cout<<value;};
};
int main()
{
TestClass f;
f.setValue(42);
f.print();
return 0;
}
填空题含有纯虚函数的类称为______。
填空题下列程序的输出结果为
Objectid=O
Obiectid=1
请将程序补充完整。
#include<iostream>
using namespace std;
class Point
{
public:
Point(int xx=0,int yy=0){X=xx;Y=yy;countP++;}
~Point(){countP--;}
int GetX(){return X;}
int GetY(){return Y;}
static void GetC(){cout<<"Object id="<<countP<<end1;}
private:
int X,Y;
static int countP;
};
______//静态数据成员的初始化
int main()
{
Point::GetC();
Point A(4,5);
A.GetC();
return 0;
}
填空题在将E-R图转换到关系模式时,实体和联系都可以表示成__________。
填空题友元类的所有成员函数都是另一个类的______函数。
填空题己知下列程序的输出结果是42,请将横线处缺失的部分补充完整。 #include<iostream> using namespace std; class Foo int value; public: Foo():value(0) void setValue(int value) ______=value; //给Foo的数据成员value赋值 void print()cout<<value; ; int main() Foo f; f.setValue(42); f.print(); return 0;
填空题下列程序的输出结果是______。
#include<iostream>
using namespace std;
class Test {
public:
Test() { cnt++;}
~Test() {cnt--;}
static int Count() {return cnt;}
private:
static int cnt;
};
int Test::cnt=0;
int main()
{
cout<<Test::Count()<<"";
Test t1,t2;
Test*oT3=new Test;
Test*pT4=new Test;
cout<<Test::Count()<<"";
delete pT4;
delete pT3;
cout<<Test::Count()<<endl;
return 0;
}