填空题一个向量(即一批地址连续的存储单元)第一个元素的存储地址是100,每个元素的长度为2,则第5个元素的地址是 【3】 。
填空题如果类B继承了类A,则称类A为类B的基类,类B称为类A的 【10】 。
填空题下面程序的输出结果是______。 #include<iostream> using namespace std; int x; void funA(int&,int); void funB(int,int&); int main() int first; int second=5; x=6; funA(first,second); funB(first,second); cout<<first<<””<<second<<””<<x<<endl; return 0; void funA(int &a,int b) int first; first=a+b; a=2*b; b=first+4; void funB(int u, int &v) int second; second=x; v=second+4; x=u+v;
填空题______允许用户为类定义一种模式,使得类中的某些数据成员及某些成员函数的返回位能取任意类型。
填空题下列程序的输出结果是 【15】 。#include <iostream>using namespace std;template <typename T>T total(T* data) Ts=0; while(*data) s+=*data++; return s;int main() int x[]=2,4,6,8,0,12,14,16,18; cout<<total(x)<<end1; return 0;
填空题以下程序的执行结果为 【8】 。 #include<iostream> using namespace std; class base public: virtual void who( ) cout < < "base class" < <end1; ; class derivel:public base public: void who( ) cout < <"derivel class" < <end1; ; } class derive2:public base public: void who( ) cout< <"derive2 class"< <end1; ; void main( ) base obj1,* p; derivel obi2; derive2 obj3; p=&obj1; p->who( ); p=&obj2; p->who( ); p=&obj3; p->who( );
填空题写出执行完下列代码段之后指定变量的值:
bool x=true,y=false,z=false;
x=x&&y‖z;
y=x‖y&&z;
z=!(x!=y)‖(y==z);
则x=false,y=false,z=
________
。
填空题阅读下面程序: #include <iostream.h> void f(int n) int x(5); static int y(10); if(n>0) ++x; ++y; cout<<x<<","<<y<<endl; void main() int m(1); f(m); 则该程序的输出结果是______。
填空题使用VC6打开考生文件夹下的工程test7_1,此工程包含一个源程序文件test7_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下: Constructor1 Constructor1 Constructor1 Destructor Constructor2 Destructor x=0 x=5 Destructor Destructor 源程序文件test1_1.cpp清单如下: #include<iostream.h> class B int X; public: B()X=0;cout<<"Constructorl"<<endl; B(int i)x=i;cout<<"Constructor2"<<endl; ~B()cout<<"Destructor"<<endl; /**********found*********/ ~B(int i)cout<<i<<"be Destructor"<<endl; void print()cout<<"x="<<x<<endl; ; void main() B *ptr; ptr=new B[2]; /**********found*********/ ptr[0]=B(0); ptr[1]=B(5); /**********found********/ for(int i=0; i<2;) ptr[i].print(); delete []ptr;
填空题函数f()的功能是将形参x的值转换为二进制数,所得二进制数的每一位数放在一维数组y中返回。二进制的最低位放在下标为0的元素中,请将程序补充完整。 void f(int x,int y[]) int m=0,n; do n=x% 【10】 ; y[m++] =n; x/=2; while(x);
填空题已知int DBL(int n){return n+n;}和long DBL(long n){return n+n)是一个函数模板的两个实例,则该函数模板的定义是{{U}} 【12】 {{/U}}。
填空题在结构化分析中,用于描述加工逻辑的主要工具有三种,即:结构化语言、判定表、{{U}} [4] {{/U}}。
填空题执行下列程序的输出结果是______:
#include<iostream>
using namespace std;
class TestClass1
{
public:
void fun1(){cout<<"TestClass1/n";}
virtual void fun2(){cout<<"TestClass1/n";}
};
class TestClass2:public TestClass1
{
public:
void fun1(){cout<<"TestClass2/n";}
void fun2(){cout<<"TestClass2/n";}
};
void f(TestClass1b.fun2();}
int main()
{
TestClass2 obj;
f(obj);
return 0;
}
填空题下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
#include<iostream.h>
class A
{
private:
int numl;
public:
A( ):numl(0){}
A(int i):numl(i){}
};
class B
{
private:
int num2;
public:
B( ):num2(0){}
B(int i):num2(i){}
int my_math(A obj1, B obj2);
};
int B::my_math(A obj1,B obj2)
{
return(obj1.numl+obj2.num2);
}
void main(void)
{
A objl(4);
B obj,obj2(5);
cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);
}
填空题在下面横线上填上适当的语句,完成程序。 #include <iostream> using namespace std; class Base int x; public: Base(int i) x=i; ~Base() ; class Derived: public Base public: ______∥完成类 Derive构造函数的定义 ; int main() Derived Obj; return 0; 在横线处应填入的语句是 【9】 。
填空题表达式“c3=c1.operator+(c2)”或“c3=operator+(c1,c2)”还可以表示为______。
填空题一个项目具有一个项目主管,一个项目主管可管理多个项目。则实体集“项目主管”与实体集“项目”的联系属于 【5】 的联系。
填空题C++的类继承中,默认的继承方式是{{U}} 【10】 {{/U}}。
填空题当循环队列非空且队尾指针等于队头指针时,说明循环队列已满,不能进行人队运算。这种情况称为{{U}} 【14】 {{/U}}。
填空题下面程序要实现的功能是打开当前目录下的文件abc,并向其追加一串字符“How are you!”,然后再关闭该文件,请将程序填写完整。 #include<fstream.h> void main() [13] f<<"How are you!"<<end1; f.close();