填空题将整个软件划分成若干单独命名和可编程的部分,称之为 【4】 。
填空题在下面横线上填上适当的语句,完成程序。
#include<iostream>
using namespace std;
class Base
{
int x;
public:
Base(int i) { x=i; }
~Base() { }
};
class Derived: public Base
{
public:
{{U}} 【14】 {{/U}}//完成类Derive 构造函数的定义
};
int main()
{
Derived Obj();
return 0;
}
填空题如下程序声明了一个电话号码类PhoneNumber,重载了流插入运算符<<,以便于电话号码的输出。请将程序补充完整。
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class PhoneNumber{
public:
void setNumber(string number){this->number=number;}
friend______(ostream&output,const PhoneNumber&nuln) //重载流插入操作符
{output<<num.number;return output;}
private:
string number;
};
int main( ){
PhoneNumber phone;
phone.setNumber("8008100598");
cout<<"The phone number is:"<<phone<<endl:
return 0;
}
填空题C++中,派生类继承了基类的全部数据成员和除{{U}} 【14】 {{/U}}之外的全部函数成员。
填空题程序中有如下语句 for(int i=0; i<5; i++) cout<<*(p+i)<<","; 能够依次输出int型一维数组DATA的前5个元素。由此可知,变量p的定义及初始化语句是______。
填空题表达式x.operator++( )还可写成 【13】 。
填空题有以下程序:
#include <fstream>
#include <string>
using namespace std;
int main ()
{
char ch[] = "The end";
ofstream outstr( "d://put.txt", ios_base: :app);
for (int i = 0; i < strlen( ch ); i++ )
outstr.put(ch[i]);
outstr.close();
return 0;
}
程序实现的功能是{{U}} {{U}} {{/U}} {{/U}}。
填空题数组是有序数据的集合,数组中的每个元素具有相同的 【3】 。
填空题下列软件系统结构图的宽度为____________。
填空题如果不能使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基数继承的成员,下列程序没有使用多态机制,其输出结果是__________。
#include
using namespace std;
class Base{
public:
Void print(){coutprint();
pd->print();
delete pd;
return 0;
}
填空题诊断和改正程序中错误的工作通常称为______。
填空题下面是复数类complex的定义,其中重载的运算符“+”的功能是返回一个新的复数对象,其实部等于两个操作对象实部之和,其虚部等于两个操作对象虚部之和;请补充完整: class complex double real; //实部 double imag; //虚部 public: complex(double r, double i):real(r),imag(i) complex operator+(complex a) return complex(______); ;
填空题有如下程序段: char C[20]="examination"; C[4]=0; cout<<c<<endl; 这个程序的输出结果是______。
填空题在关系模型中,一个关系的属性名表称为 【5】 ,也就是二维表的表框架,相当于记录型。
填空题请在下列程序中的横线处填写正确的语句。
#include<iostream>
using namespace std;
class Base{
public:
void fun(){cout<<“Basefun”<<endl;}
);
class Derivde:public Base{
public:
void fun(){
//调用基类的函数fun()
cout<<“Derived fun”<<endl;
}
};
填空题程序段的输出结果是 [7] 。 int a=12,b=12; cout<<- -a<<“”<<++b;
填空题在执行语句序列: int i=0; do i++; while(i*i<10); 时,do后面的循环体语句i++被执行的次数为______。
填空题若有以下程序:#include <iostream>using namespace std;class Basepublic: void who() cout<<"Base"<<end1;;class Derivedl: public Basepublic: void who() cout<<"Derived"<<end1; ;int main() Base *p; Derived1 obj1; p= p->who(); return 0;则该程序运行后的输出结果是 【9】 。
填空题表达式operator + (x,y)还可以表示为 【14】 。
填空题非成员函数应声明为类的 【9】 函数才能访问这个类的private 成员。