填空题下列程序的执行结果为{{U}} 【11】 {{/U}}。
#inciude<iostream, h>
int f(int i) { return + +i; }
int g(int }
void main()
{ int a, b;
a=b=0;
a+ =f(g(A) );
b+=f(f(B) );
cout<<%= "<<a<<", b="<<(b<<end1;
}
填空题下面程序的结果为 【7】 。 #include<iostream.h> void main( ) int a=1,b=2; bool c=1; if((a>b)||c) cout<<"true"<<endl; else cout<<"false"<<endl;
填空题函数不能直接引用类中说明的非静态成员,这里指的成员是{{U}} 【11】 {{/U}}。
填空题下列程序的输出结果是{{U}} 【13】 {{/U}}。
#include <iostream>
using namespace std;
int main()
{
int data=1;
int
data+=5;
r+=5;
cout<<data<<end1;
return 0;
}
填空题下面是一个栈类的模板,其中push函数将元素i压入栈顶,pop函数弹出栈顶元素。栈初始为空,top值为0,栈顶元素在stack[top-1]中,在下面画线处填上适当语句,完成栈类模板的定义。 template<class T> class T stack enunlsize=1000; T stack[size]; in[top; public: T stack( ):top(0) void push(cons[T &i) if(top<size)stack[top++]=i; T pop( ) if(top==0)exit(1); //栈空时终止运行 return______; ;
填空题CASE是一组 [4] 的集合,可以辅助软件开发生命周期各阶段进行软件开发。
填空题如下程序声明了一个二维图形类TwoDShape,从其派生出矩形类Rec。
#include<iostream>
#include<string>
using namespaee std,
class TwoDShape{// 二维图形类
char name[20];
public:
TwoDShape (char * n="unknown") {
strcpy(name, n);
}
Char * getName(){return name;}
【 】 =0;
};
class Rec: public TwoDShape{
double width, height
public:
Rec(double w-=0. 0,double h=0. 0):TwoDShape("rectangle")
{ width=w; height=h; }
double getWidth() {return width;}
double getHeight() {return height;}
double area() {return width * height;}
};
int main() {
TwoDShape * shape;
Shape=new Rec(2.1,3.0);
cout<<"object is"<<shape->getName()<<"\n";
cout<<"Area is"<<shape->area()<<"\n";
return 0
}
请将程序补充完整,使程序在运行时输出:
abject is triangle
Area is 6.3
填空题设一棵二叉树的中序遍历结果为ABCDEFG,前序遍历结果为DBACFEG,则后序遍历结果为______。
填空题请按下面注释的提示,将类B的构造函数定义补充完整。
C1assA
{
int a;
public:
A(int aa=O){a=aa;}
};
class B:public A {
int b;
A c;
public:
//用aa初始化基类A,用aa+1初始化类对象成员c
B(int aa}:【 】{b=aa+2}
};
填空题C++程序第1条语句是从
________
函数开始执行的。
填空题在C++语言编辑过程中,包含预处理过程,编译过程,和{{U}} [3] {{/U}}三个过程。
填空题非成员函数只有在声明为类的 【8】 才能访问这个类的所有private成员。
填空题构造函数与析构函数所调用的虚函烽是所在类的函数,因此调用时实现的是 [14] 联编。
填空题下面程序的打印结果是{{U}} 【11】 {{/U}}。
#include <iostream>
using namespace std;
class Base
{
public:
Base(int x)
{
a=x;
}
void show()
{
cout<<a;
}
private:
int a;
};
class Derived : public Base
{
public:
Derived(int i) :Base(i+1) ,b(i) { }
void show()
{
cout<<b;
}
private:
int b;
};
int main ( )
{
Base b(5) , *pb;
Derived d(1);
pb=
pb->show();
return 0;
}
填空题补充完整下面的模板定义:
template<class Type> //Type为类型参数
class Xtwo{ //由两个Type类型的数据成员构成的模板类
Type a;
Type b;
public:
Xtwo(Type aa=0,Type bb=0):a(aA) ,b(bB) { }
int Compare( ){ //比较a和b的大小
if(a>B) return 1;
else if(a==B) return 0;
else return-1;
}
Type Sum( ){return a+b;} //返回a和b之和
Type Mult( ); //函数声明,返回a和b之乘积
};
template<class Type>
______ ::Mult( ){return a*b;} //Mult函数的类外定义
填空题在C++类中,默认的数据成员的访问权限是{{U}} {{U}} {{/U}} {{/U}}。
填空题函数定义的格式是______函数名(形式参数表)函数体。
填空题下列软件系统结构图的宽度为________
填空题已知有函数f的定义如下: int f() static int s=0; s+=2; return s; 则在某程序中第2次执行函数调用语句f();时,函数f的返回值是______。
填空题在C++中的实型数据分为三种类型,即单精度float、双精度double和______。
