填空题设px是指向一个类动态对象的指针变量,则执行"delete px;"语句时,将自动调用该类的______。
填空题有以下程序: #include <iostream> using namespace std; long fib( int n ) if(n>2) return ( fib( n-1 )+fib( n-2 ) ); else return 2; int main() cout<<fib(3)<<end1; return 0; 则该程序的输出结果应该是 【12】 。
填空题下列程序将x、y和z按从小到大的顺序排列,请将下面的函数模板补充完整。
template<class T>
void order({{U}} 【15】 {{/U}})
{
T a;
if(x>y)
{
a=X;x=y;y=a;
}
if(y>z)
{
a=y;y=z;z=a;
}
if(x>y)
{
a=X;x=y;y=a;
}
}
填空题构造函数的主要作用是{{U}} 【8】 {{/U}}。
填空题在下面横线上填写适当的语句,完成程序。 #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; 在横线处应填入的语句是______。
填空题一个算法通常由两种基本要素组成:一是对数据对象的运算和操作;二是______。
填空题执行语句cout<<setw(6)<<setfill("*")<<12<<endl; 结果是
________
。
填空题补充完整下面的类定义:
const double PI=3.14;
class Circle{ //圆形物体的抽象基类
protected:
double r; //半径
public:
Circle(double radius=0):r(radius){}
{{U}} (13) {{/U}}; //计算圆形物体表面积的纯虚函数声明
};
class Cylinder:public Circle{ //圆柱体类
double h; //高度
public:
Cylinder(double radius=0,double height=0);
Circle(radius),h(height){}
Virtual double Area( ){return 2*PI*r*(r+h);} //计算圆柱体的表面积
};
填空题阅读下面程序:
#include <iostream.h>
int fun( int a, int b )
{
int c;
c=a*b;
return c;
}
void main()
{
int a=3,b=5,c=4,x=0;
x=fun(fun(a, b),c);
cout<<x<<end1;
}
其运行结果是{{U}} 【9】 {{/U}}。
填空题有以下程序
#include <iostream>
using namespace std;
class Base
int a;
public:
Base(int x){ a=x;}
void show(){cout<<a; }
};
class Derived: public Base
{
int b;
public:
Derived(int i):Base(i+1),b(i) { }
void show(){ cout<<b; }
};
int main()
{
Base b(5),*pb;
Derived d(1);
pb=
pb->show();
return 0;
}
运行后的打印结果是{{U}} 【14】 {{/U}}。
填空题在下面的类定义中,this指针的用途是 【11】 。 #include <iostream. h> class Sample int x,y; public: Sample(int i,int j)x=i;y=j; void asstgn(Sample sa): ; void Sample: :assign(Sample p) if (this! = y=p.y;
填空题以下程序段的执行结果为{{U}} 【15】 {{/U}}。
#include<iostream.h>
#define PLUS(x, y) x+ y
void main()
{
int x=1, y=2,z=3,sum;
sum=PLUS(x+ y, z)*PLUS(y, z);
cout<<"SUM="<<sum;
cout<<end1;
}
填空题阅读下面程序: #include<iostream.h> void fun1(char a,char b) char c; c=a;a=b;b=c; void fun2(char c=a;a=b;b=c; void main() char a,b; a='x';b='y'; fun1(a,b);cout<<a<<b; a='x';b='y'; fun2(a,b);cout<<a<<b; 则该程序的输出为______。
填空题多态性分为两类:编译时的多态性和______。
填空题一个类中有______个析构函数。
填空题下面的函数利用递归实现了求1+2+3+……+n的功能: int sum(int n) if(n= =0) return 0; else return n+sum(n-1); 在执行sum(10)的过程中,递归调用sum函数的次数是______。
填空题下列程序的输出结果是______。 #include<stdio.h> #define N 5 int fun(int *s,int a,int n) int j; *s=a;j=n; while(a!=s[j])j--; return j; void main() int s[N+1];int k; for(k=1;k<=N;k++)s[k]=k+1; printf("%6d/n",fun(s,4,N));
填空题有以下程序
#include<iostream>
using namespace std;
class MyClass
{
public:
MyClass();
~MyClass();
Static int s;
void SetValue (int val);
};
int MyClass::s=0;
MyClass::MyClass()
{
s++;
}
void MyClass::SetValue(int Val)
{
s=val;
}
int main()
{
MyClass my[3],*p;
p=my;
for(int k=0;k<3;k++)
{
p->SetValue(k+1);
p++;
}
cout<<MyClass::s<<endl;
return 0;
}
运行后的输出结果是{{U}} 【11】 {{/U}}。
填空题对下列二又树进行中序遍历的结果为______。
填空题当数据的物理结构(存储结构、存取方式等)改变时,不影响数据库的逻辑结构,从而不致引起应用程序的变化,这是指数据的{{U}} 【5】 {{/U}}。
