填空题请将下列类定义补充完整。
class Base{public:void fun(){tout<<"Base::fun"<<endl;}};
class Derived:public Base
{
public:
void fun()
{
______//显示调用基类的fun函数
cout<<"Derived::fun"<<endl;
};
填空题对虚函数的调用有两种方式:______和______。
填空题表达式x.operator++( )还可写成{{U}} 【13】 {{/U}}。
填空题要在类的对象上使用运算符,除了运算符 【7】 和 【8】 以外,其他的运算符都必须被重载。
填空题头文件{{U}} 【8】 {{/U}}中包含了处理用户控制的文件操作所需的信息。
填空题为了便于对照检查,测试用例应由输入数据和预期的【 】两部分组成。
填空题作为成员函数重载的运算符,第一操作数就是参数表中隐含的________所指向的对象,因此并不显示地出现在参数表中。
填空题软件工程包括三个要素,分别为方法、工具和{{U}} 【4】 {{/U}}。
填空题为解决在多重继承环境中因公共基类带来的【 】问题,C++语言提供了虚基类机制。
填空题语句cout<<setprecision (3)<<3.1415926<<end1;的输出为{{U}} 【8】 {{/U}}。
填空题下列程序的输出结果是______。
#include<iostream.h>
template<class T>
T max(T x[],int n)
{
int i;
T maxv=x[0];
for(i=1;i<n;i++)
if(maxv<x[i])
maxv=x[i];
return maxv;
}
void main( )
{
int a[]={3,2,7,6,8,9};
double b[]={1.2,3.4,2.5,7.3,6.8};
cout<<max(a,4)<<","<<max(b,3)<<endl;
}
填空题函数fun的功能是将一个数字字符串转换为一个整数,请将函数补充完整。 int fun(char *str) int num=0; while(*str) num*=10; num+=______; str++; return num;
填空题将下面程序补充完整。 #include <iostream> using namespace std; class Base public: 【14】 fun()return 0; //声明虚函数 ; class Derived:public Base public: x,y; void SetVal(int a,int b) int fun()return x+y; ; void 【15】 SetVal(int a,int b)x=a;y=b; //类Derived成员函数 void main() Derived d; cout<<d.fun()<<endl;
填空题下面程序的运行结果是 【9】 。 #include <iostream> using namespace std; void fun(int &a, int b=3) static int i=2; a = a + b + i; i = i + a; int main() int x=5, y=2; fun(x, y); cout<<x<<","; fun(x); cout<<x<<end1; return 0;
填空题有如下程序:
#include<iostream>
using namespace std;
class Animal{
public:
virtual char*getType( )const{ return "Animal";}
virtual char*getVoice( )const{ return "Voice";)
};
class Dog: public Animal{
public:
char*getType( )const{return "Dog";)
char*getVoice( )const{return "Woof";}
};
void type(Animal}
void sDeak(Animal a){ cout<<a.getVoice( );}
int main( ){
Dog d;type(d);cout<<"speak";speak(d);cout<<endl;
return 0;
}
运行时的输出结果是______。
填空题Staff类含有int型数据成员ID,两个Staff对象相等是指它们的ID相同。下面的函数重载了运算符==,它用来判断两个Staff对象是否相等,相等时返回true,否则返回false。请将横线处缺失部分补充完整。
bool Staff::Staff==(const Staff &s)
{
return( {{U}}【13】 {{/U}})
}
填空题已知f1(int)是类A的公有成员函数,并将指针p定义为可以指向函数f1的指针类型,则可以实现让p是指向成员函数f1()的指针的语句为{{U}} 【7】 {{/U}}。
填空题如下程序定义了“单词”类word,类中重载了
#include
using namespace std;
class Word{
public:
Word(string s) : str(s) { }
string getStr(){ return str; }
{{U}}【14】{{/U}} const { return (str
填空题在结构化设计方法中,数据流图表达了问题中的数据流与加工间的关系,且每一个______实际上对应一个处理模块。
填空题下列程序的输出结果是{{U}} 【8】 {{/U}}
#include<iostream>
using namespace std;
int &get Var(int*pint)
{
return *pint;
}
int main()
{
int a=10;
getvar(&A) =20;
cout<<a<<end1;
return 0;
}