填空题下列程序编译时发现pb->f(10);语句出现错误,其原因是 【12】 。 # include<iostream. h> class Base public: void f(int x)cout<<"Base:"<<x<<endl; ; class Derived: public Base public: void f(char * str)cout<<"Derivcd:"<<str<<endl; ; void main(void) Derived * pd=new Derived; pd->f(10)
填空题若要在C盘根目录下作为二进制文件打开文件test.dat,则应该用的语句是 【15】 。
填空题下列程序的执行结果为________。
#include<iostream.h>
class Point
{
public:
Point(double i,double j){x=i;y=j;}
double Area( )const{return 0.0;}
private:
double x,y;
};
class Rectangle:public Point
{
public:
Rectangle(double i,double J,double k,double 1);
double Area( )const(return w*h;}
private:
double w,h;
};
Rectangle::Rectangle(double i,double j,double k,double 1):Point(i,j)
{
w=k;h=l;
}
void fun(Point
}
void main( )
{
Rectangle rec(3.0,5.2,15.0,25.0);
fun(rec);
}
填空题下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false。请在画线处填上适当内容,实现该函数。
bool fun(char*str)}
int i:0,j=0;
while(str[j])
________
;
for(J--;i<j&&str[i]==str[J];i++,J--);
return i
______
J;
}
填空题已知类sample是一个抽象类,其成员函数display是无形参、无返回类型的纯虚函数,请完成其声明:
class sample {
public:
sample() {};
________
};
填空题已知:
double A (double A) { return ++a;}和int A(int A) { return ++a;}是一个函数模板的两个实例,则该模板定义为{{U}} 【15】 {{/U}}。
填空题下面程序实现输出从“!”开始的91个ACCII字符及码值,要求每行输出7项。请完成程序。
#include<iostream.h>
void main( ) {
char c= "!";
int d , n=1;
do {
while (n<=7) {
d=c;
cout<<c<< "=" <<d<<“”;
c++
n++;
}
cout<< "/n" ;
{{U}} [7] {{/U}};
} while(c<= '!' +90)
cout<< "/n" ;
}
填空题算法的空间复杂度是指 【1】 。
填空题若有以下程序:#include <iostream>using namespace std;class Basepublic: Base() x=0; int x;;class Derived1: virtual public Basepublic: Derived1() x=10; ;class Derived2: virtual public Basepublic: Derived2() x=20; ;class Derived: public Derived1, protected Derived2 ;int main() Derived obj; cout<<obj.x<<end1; return 0;该程序运行后的输出结果是 【15】 。
填空题{{U}}【6】 {{/U}}是C++语言程序的入口。
填空题在面向对象的程序设计中,将数据和处理数据的操作封装成一个整体就定义了一种事物的类型,称作“类”。类是一种抽象的概念,属于该类的一个实例叫做“______”。
填空题在一个容量为25的循环队列中,若头指针front=16,尾指针rear=9,则该循环队列中共有______个元素。
填空题下面程序编译时发现ma[3]=9错误,其原因是______。 #include<iostream.h> class FunArray int*pa; //指向一个数组空问 int size; //数组元素个数 public: FunArray(int a[],int thesize):pa(a),size(thesize) int Size( )return size; ; void main( ) int s[]=3,7,2,1,5,4; FunArray ma(s,sizeof(s)/sizeof(int)); ma[3]=9; cout<<ma[3]<<endl;
填空题类是用户定义的类型,具有类类型的变量称作
________
。
填空题已知:double A(double A) return ++a;和int A(int A) return++a;是一个函数模板的两个实例,则该函数模板定义为 【13】
填空题下面是复数类complex的定义,其中作为友元函数重载的运算符“--”的功能是将参数对象的实部减1,然后返回对该对象的引用。请补充完整。
class complex
{
private:
int real;
int imag;
public:
complex(int r=0,int i=0):real(r),imag(i){}
void show()
{
cout<<real<<(imag<0?"-":"+")<<imag<<'i';
}
{{U}}【11】 {{/U}};
};
complex& operator-- (complex &C)
{
C.real--;
return C;
}
填空题若已定义,以下fun函数的功能是:在第一个循环中给前10个数组元素依次赋1、2、3、 4、5、6、7、8、9、10;在第二个循环中使a数组前10个元素中的值对称折叠,变成1、 2、3、4、5、5、4、3、2、1。请填空。 fun( int a[]) int i, for(i=1;i<=10;i++) 【11】 =i; for(i=0;i<5;i++) 【12】 =a[i];
填空题对于只在表的首、尾两端进行插入操作的线性表,宜采用的存储结构为 [3] 。
填空题假定用户没有给一个名为MyClass的类定义析构函数,则系统为其定义的默认析构函数首部形式为 【7】 。
填空题定义如下变量和数组:
int i;
int y[2][3]={2,4,6,8,10,12};
则下面语句的输出结果是{{U}} 【7】 {{/U}}。
for(i=0;i<2;i++)
cout<<y[1-i)[i+1]<<",";
