填空题虚函数必须是类的{{U}} 【9】 {{/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;
}
在横线处应填入的语句是{{U}} 【14】 {{/U}}。
填空题若有以下程序:
#include <iostream>
using namespace std;
class Base
{
public:
void who()
{
cout<<"class Base"<<end1;
}
};
class Derivedl : public Base
{
public:
void who()
{
cout<<"class Derivedl"<<end1;
}
};
class Derived2 : public Base
{
public:
void who()
{
cout<<"class Derived2"<<end1;
}
};
int main()
{
Base *p;
Derivedl obj1;
Derived2 obi2;
p=
p=
p->who ( );
return 0;
}
则该程序运行后的输出结果是
________
。
填空题下列程序的输出结果为______。 #include <iostream.h> void main() int a[]=10,20,30,40,*pa=a; int * pb++; cout<<*pa<<endl;
填空题以下程序的执行结果是______。 #include <iostream.h> class Sample int n; public: Sample() Sample(int m) n=m; int return n; void disp() cout<<"n="<<n<<endl; ; void main() Sample s(10); (s--)++; s.disp();
填空题设有二维数组A[0..9,0..19],其每个元素占两个字节,第一个元素的存储地址为100,若按行优先顺序存储,则元素A[6,6]的存储地址为,{{U}} 【1】 {{/U}}。
填空题对于嵌套的if…else语句,C++语法规定else总是与{{U}} 【7】 {{/U}}匹配。
填空题以下程序输出的结果是{{U}} 【10】 {{/U}}。
#include<iostream.h>
void main()
{
int a=5,b=4,c=3,d;
d=(a>b>c);
cout<<d;
}
填空题下面程序运行时输出结果为______。 #include <iostream.h> #include <malloc.h> class Rect public: Rect(int l,int w) length=l;width=w;) void Print() cout<<"Area:"<<length*width<<endl; void *operator new(size-t size) return malloc(size); void operator delete(void *p)free(p private: int length,width; ; void main() Rect *p; p=new Rect(5,4); p->Print(); deletep;
填空题下列程序的执行结果为{{U}} 【15】 {{/U}}。
#include<iostream.h>
void main( )
{
cout.fill('*');
cout.width(10);
cout<<"hello"<< end1;
}
填空题假定p所指对象的值为25,p+1所指对象的值为46,则执行“*p++;”语句后,p所指的对象的值为{{U}} 【11】 {{/U}}。
填空题下面程序的输出结果为 【7】 。 #include<iostream> using namespace std; void initialize (int print No,int state=0); void initialize(int printNo=1,int state); int main() initialize(); retum 0; void initialize (int printNo,int state) cout<<printNo<<","<<state<<end1;
填空题指针数组是由______构成的数组。
填空题以下程序的输出结果是 【9】 。 #include<iostream.h> void main( ) char s[ ]="abcdef";s[3]='/0'; cout<<s<<endl;
填空题函数重载要求重载的函数必须有和原函数一样的 【10】 。
填空题执行语句cout<<setw(6)<<setfill('*')<<12<<endl; 结果是 【6】 。
填空题友元类的所有成员函数都是另一个类的
________
函数。
填空题______成员函数中不能直接引用类中说明的非静态成员。
填空题类ostream的成员函数______用于执行无格式输出,成员函数put用于输出单个字符。
填空题下面是一个递归函数,其功能是使数组中的元素反序排列。请将函数补充完整。
void reverse(int *a, int size){
if(size<2) return;
int k=a[0];
a[0]=a[size-1];
a[size-1]=k;
reverse(a+1, {{U}} 【9】 {{/U}});
}
