填空题分析下列程序,并写出运行结果{{U}} [9] {{/U}}。
#include<iostream.h>
void main(){
int x[10]:
int i=5,*ptr=x;
*(ptr+i)=10;
cout<<x[i]<<end1;
填空题 【13】 允许用户为类定义一种模式,使得类中的某些数据成员及某些成员函数的返回值能取任意类型。
填空题当循环队列非空且队尾指针等于队头指针时,说明循环队列已满,不能进行入队运算。这种情况称为 【2】 。
填空题写出执行完下列代码段之后指定变量的值: boo1 x=true,y=false,z=false; x=x y=x‖y z=!(x!=y)‖(y==z), 则 x=false, y=false, z= 【6】 。
填空题有以下程序:
#include <iostream>
using namespace std;
class Base
{
private:
int a,b;
public:
Base(int x, int y)
{
a=x;
b=y;
}
void Show()
{
cout<<a<< ',' <<b<<end1;
}
};
class Derived : public Base
{
private:
int c;
public:
Derived(int x, int y, int z) : Base(x,y),c(z) {}
void Show()
{
cout<<c<<end1;
}
};
int main()
{
Base b(50,50),*pb;
Derived d(10,20,30);
pb=
pb->Show();
return 0;
}
运行后的打印结果为{{U}} 【14】 {{/U}}
填空题使用VC++6.0打开考生文件夹下的源程序文件1.cpp。本程序要求输入一个字符串,然后将其中的小写字母改成大写字母,字符可能输入多行,当输入字符“?”时,默认字符输入结束,最后把结果输出到屏幕中。 注意:不要改动main函数,不能增加或删除行,也不能更改程序的结构,错误的语句在//******error******的下面。 试题程序: #include<iostream.h> void main() int i=0; char str[120]; cout<<"Enter a string end with'?'."<<end1; //********error******** cin.getline(str,120); //********error******** while(str) //*****岳**error******** if(str[i]>='a') str[i]=str[i]-'a'+'A'; i++; cout<<str<<end1; return;
填空题 【4】 是在进行了成功的测试之后才开始的。它与软件测试不同,测试的目的是发现错误,进一步诊断和改正错误,则是调试的任务。
填空题假设int a=1,b=2;,则表达式(++a/B) *b--的值为{{U}} 【8】 {{/U}}。
填空题若有int x[5],*p=x;则数组元素x[3]可以表示为*(p+{{U}} [8] {{/U}}),也可以表示为p[3]。
填空题若a=12,b=14,c=0,则表达式“((y=(a>B) ?a:B) >C) ?y:c”的值为 【6】 。
填空题按照软件测试的一般步骤,集成测试应在______测试之后进行。
填空题main函数中发生编译错误的语句是{{U}} 【12】 {{/U}}。
# include <iostream. h>
class A
{
public:
int a;
const int b:
A() :a(10) ,b(20) {
void fun() const
{
cout<<"a="<<a<<"/tb="<<b<<end1;
}
};
void main( )
A obj1;
const A * ptr = new A:
ptr =
ptr->a=lO0;
ptr->fun(),
}
填空题使用VC6打开考生文件夹下的工程test40_1,此工程包含一个源程序文件test40_1.cpp,但该程序运行有问题,请改正函数中的错误,使该程序的输出结果为: The first result is 5 The second result is 2 The third result is 2 The fourth result is 6 源程序文件test40_1.cpp清单如下: #include <iostream.h> int subtraction (int a, int b) int r; r=a-b; /***************** found ************************/ return int main () int x=5, y=3, z; z = subtraction (7,2); cout << "The first result is "<< z << '/n'; cout << "The second result is "<< subtraction(7,subtraction (7,2)) << '/n'; /**************** found *************************/ cout << "The third result is "<< subtraction ( /***************** found ************************/ z= 4 + *subtraction (x,y); cout << "The fourth result is "<< z << '/n'; return 0;
填空题已知下列程序的输出结果是42,请将画线处缺失的部分补充完整。
#include <iostream>
using namespace std;
class Foo {
int value;
public:
Foo 0=:value(0) {}
void setValue(int value)
{
________
= value; }//给Foo的数据成员value赋值
void print() { cout << value; }
};
int main()
{
Foo f;
f.setValue(42);
f.print();
return();
}
填空题在面向对象方法中,信息隐蔽是通过对象的{{U}} {{U}} {{/U}} {{/U}}来实现的。
填空题C++语言程序的注释可以出现在程序中的任何地方,一个注释以 {{U}}【7】 {{/U}}作为开始和结束的标记。
填空题使用VC++6.0打开考生文件夹下的源程序文件1.cpp,该程序运行时有错误,请改正其中的错误,使程序正确运行,并且使程序输出的结果为 OK 注意:错误的语句在//******error******的下面,修改该语句即可。 试题程序: #include<iostream.h> class TC public: TC() a=b=0; private: int a,b; ; class TC1:public TC public: TC1() //******error****** virtual void func(); ; class TC2:public TC1 public: TC2() a=0; b=0; void func() //******error****** cout<<"OK"<<end1; private: int a; int b; ; void main() TC2 obj; //******error****** TC1 *p=(TC1*)obj; p—>func();
填空题下面程序的运行结果是{{U}} 【9】 {{/U}}。
#include <iostream>
using namespace std;
class count
{
static int n;
public:
count()
{
n++;
}
static int test()
{
for(int i=0;i<4;i++)
n++;
return n;
}
};
int count::n = O;
int main()
{
cout<<count:: test()<<" ";
count c1, c2;
cout<<count:: test()<<endl;
return 0;
}
填空题已知程序的结果为1 2 3,请填空。
#include<iostream.h>
template<class T>
class A
{
public:
T x,y,z;
void display() {cout <<x << " " <<y << " " <<z;}
};
void main()
{
A<int>a1;
{{U}} 【12】 {{/U}}
{{U}} 【13】 {{/U}}
{{U}} 【14】 {{/U}}
a1.display();
}
填空题在深度为6的满--X树中,叶子结点的个数为 【2】 。