填空题下列程序运行后的输出结果是______。
#include<iostream.h>
void main()
{
int s=0,k;
for(k=7;k>=O;k--)
{
switch(k)
{
case 1:
case 4:
case 7:s++;break;
case 2:
case 3:
case 6:break:
case 0:
case 5:s+=2;break:
}
}
cout<<"s="<<s<<endl;
}
填空题在C++语言中,唯一的一个三目运算符是 【7】 。
填空题有以下程序:
#include <iostream>
using namespace std;
int f(int);
int main()
{
int i;
for(i=0;i<5;i++)
cout<<f(i)<<" ";
return 0;
}
int f(int i)
{
static int k=1;
for(;i>0;i--)
k+=i;
return k;
}
运行后的打印结果是{{U}} 【9】 {{/U}}。
填空题数据的逻辑结构是从逻辑关系上描述数据,它与数据的 【2】 结构无关。
填空题对基类数据成员的初始化必须在派生类的构造函数中的______处执行。
填空题表达式float(25)/4 int(14.4)%5的值分别为{{U}} 【6】 {{/U}}和{{U}} 【7】 {{/U}}。
填空题C++语句const char*const p="hello";,所定义的指针p和它所指的内容都不能被{{U}} 【10】 {{/U}}。
填空题使用VC++6.0打开考生文件夹下的源程序文件1.cpp,该程序运行时有错,请改正程序中的错误,使程序输出的结果为
Number=7 Number=12
注意:错误的语句在//******error******的下面,修改该语句即可。 试题程序:
#include<iostream.h> class TC {
public: //******error****** TC(int
i):Number=i { //******error******
return Number; } void set(int
i) { Number=i; }
void display() {
cout<<"Number="<<Number<<end1; }
private: int Number; }; void
main() { //******error******
TC *p=new TC; p—>display();
p—>set(12); p—>display(); return;
}
填空题我们通常用到的cin>>,是属于 【15】 输入。
填空题以下程序运行后的输出结果是{{U}} 【14】 {{/U}}。
#include <iostream>
#include <string>
using namespace std;
class Y;
class X
{
int x;
char *strx;
public:
X(int a, char *str)
{
x=a;
strx=new char[strlen(str)+l];
strcpy(strx,str);
}
void show(Y
};
class Y
{
private:
int y;
char *stry;
public:
Y(int b,char *str)
{
y=b;
stry=new char[strlen(str)+l];
strcpy(stry, str);
}
friend void X::show(Y
};
void X::show(Y
cout<<ob.stry<<end1;
}
int main()
{
X a(10,"stringX");
Y b(20,"stringY");
a. show (B) ;
return 0;
}
填空题有如下类声明:
class MyClass
{
int i;
private:int j;
protected: int k;
public: int m, n;
其中,私有成员的数量为{{U}} {{U}} {{/U}} {{/U}}。
填空题下面程序的结果为
________
。
#include<iostream.h>
voidmain()
{
int a=1,b=2;
bool c=1;
if((a>b)||(c)cout <<"ture" <<end1;
else
cout <<"false" <<end1;
}
填空题{{U}} 【3】 {{/U}}是一种信息隐蔽技术,目的在于将对象的使用者和对象的设计者分开。
填空题以下程序的执行结果是{{U}} 【11】 {{/U}}。
#include<iostream.h>
#include<stdlib.h>
class Sample
{
public:
int x,y;
Sample(){x=y=0;}
Sample(int a,int b) {x=a;y=b; }
void disp()
{
cout<<"x="<<x<<",y="<<y<<end1;
}
};
void main() {
Sample s1(2,3);
s1.disp();
}
填空题在进行模块测试时,要为每个被测试的模块另外设计两块:驱动和承接模块(桩模块)。其中
______
的作用是将测试数据传送给被测试的模块,并显示被测试模块所产生的结果。
填空题C++语言提供的基本控制结构可以分为3种类型:顺序结构、 【9】 和循环结构。
填空题C++语言提供的“::”运算符的作用是在同名局部变量的作用域中访问 【8】 。
填空题执行语句int a,b,c;scanf("%d,%d%d", 如果输入形式为10,12,14,则 a,b,c的值分别是 【7】 。
填空题下列程序的输出结果是 【10】 。 #include<iostream> using namespace std; void fun (int &rf) rf*=2; int main() int num:500; fun(num); cout<<num<<endl; return 0;
填空题数据的基本单位是{{U}} 【2】 {{/U}}。
