填空题数据的逻辑结构有线性结构______两大类。
填空题C++语言支持的两种多态性分别是编译时的多态性和 【13】 的多态性。
填空题友元类的所有成员函数都是另一个类的 【8】 函数。
填空题函数Min的功能是返回具有n个元素的数组array中的最小值。请将横线处的缺失部分补充完整,使得程序的输出结果为1.24。
#include<iostream>
using namespace std;
template<typename T>
T Min(T*array,int n){
T min=array[0];
for(int i=1;i<n;i++)
if(array[i]<min)min=array[i];
return min;
}
int main(){
double arr[8]={5.2,48.45,41.01,42,51.2,1.24,14.12,42};
cout<<______;
return 0;
}
填空题有以下程序:
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
fstream file;
file.open("abc.txt", ios :: in);
if ( !file )
{
cout<<"Can not open abc.txt"<<end1;
abort();
}
char buf[ 80 ];
int i = 0;
while (!file.eof())
{
file.getline(buf,80);
i++;
}
cout<<"Lines :"<<i<<end1;
file.close();
return 0;
}
程序实现的功能是{{U}} 【15】 {{/U}}。
填空题已知下列程序的输出结果是42, 请将画线处缺失的部分补充完整。
#include<iostream>
using namespace std;
class Foo
int value;
public:
Foo( ): value(0) {}
void setValue(int value)
{{{U}} {{U}} {{/U}} {{/U}}=value; //给Foo的数据成员value赋值}
void print( ) { cout<<value;}
};
int main( )
{
Foo f;
f.setValue(42);
f.print();
return 0;
填空题main函数中发生编译错误的语句是 【12】 。 # 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(),
填空题下面程序的输出结果是{{U}} 【15】 {{/U}}。
#include <iostream>
using namespace std;
class base
{
protected:
int a;
public:
base(){cout<<"0":}
};
class basel: virtual public base
{
public:
base1(){ cout<<"1";}
};
class base2 : virtual public base
{
public:
base2(){cout<<"2";}
};
class derived : public base1,public base2
{
public:
derived () {cout<<"3"; }
}
int main ()
{
derived obj;
cout<<end1;
return 0;
}
填空题C++语言中关键字运算符有new,delete和 【6】 。
填空题operator是运算符重载时必须使用的关键字,它和被重载的运算符连在一起,作为运算符函数的专用函数名,务必把该函数说明为 【11】 的。
填空题下面程序的功能是将字符数组a中下标值为偶数的元素从小到大排列,其他元素不变,请填空。 #include<iostream.h> #include<string.h> void main( ) char a[ ] ="clanguage", t; int I ,j, k; k=strlen(a) ; for(i=0;i<=k-2;i+=2) for(j=i+2;j<=k; 9 ) if( 10 ) t=a[i] ;a[i] =a[j] ;a[j] =t; cout < < a; cout < < endl;
填空题下列程序的输出结果是______。 #include<iostream> using namespace std; void fun(int &rf) rf*=2; int main() int num=500; fun(num); cout<<num<<endl; return 0;
填空题假定q所指对象的值为25,q+1所指对象的值为46,则执行"(*q)++;"语句后,q所指对象的值为______。
填空题下面程序的输出结果是 【8】 。 #include <iostream> using namespace std; int d=1; fun(int p) static int d = 5; d+ =p; cout<<d; return (d) ; void main ( ) int a =3; cout<<fun ( a + fun (d) )<<endl;
填空题在下面的程序的横线处填上适当的语句,使该程序的输出为12。 #include 〈iostream〉 using namespace std; class Base public: int a; Base(int i) a=i; ; class Derived : public Base int a; public: Derived(int x) : Base(x),b(x+1) void show() ______; //输出基类数据成员a的值 cout〈〈b〈〈end1; ; int main() Derived d(1); d.show(); return 0;
填空题虚基类说明格式如下:slass派生类名______<继承方式><基类名>。
填空题已知类sample是一个抽象类,其成员函数display是无形参、无返回类型的纯虚函
数,请完成其声明;
class sample{
public:
sample(){);
______
);
填空题下面程序的输出结果为:Base:: fun,请将程序补充完整。#include <iostream.h>class Basepublic: 【12】 fun()cout<<"Base::fun"<<end1:class Derived : public Basepublic: 【13】 fun() cout<<"Derived::fun"<<end1; ;int main() Base a,*pb; Derived b; pb = pb->fun(); return 0;
填空题有如下程序: #include<iostream> using namespace std; class Con char ID; public: Con():ID('A')cout<<1; Con(char ID) :ID(ID) cout<<2; Con(Con char getID()constreturn ID; ; void show(Con C) cout<<c.getID(); int main() Con c1; show(c1); Con c2('B'); show(c2); return 0; 执行上面程序,输出是______。
填空题下列程序中函数fun的功能是统计person所指结构体数组中所有性别(sex)为M的记录个数,存入变量n中,并作为函数值返回,请填空。 #include<stdio.h> #define N 3 typedef struct int num;char nam[10];char sex;) ss; int fun(SS person[]) for(i=0;i<N;i++) int i,n=0; if(______=='M')n++; return n; void main() SS W[N]=1,"AA",'F'),2,"BB",'M'),3,"CC",'M';int n; n=fun(w);printf("n=%d/n",n);
