填空题模板使我们可以用一个代码段指定一组相关函数(称为 ______ )或一组相关类(称为 ______。
填空题下列程序的输出结果是{{U}} 【13】 {{/U}}
#include<iostream>
using namespace std;
template<typenameT>
Tfun(Ta,TB) {return (a<=B) ?a:b;}
int main ()
{
cout<<fun(3,6)<<','<<fun(3.14F,6.28F)<<end1;
return 0;
}
填空题类继承中,缺省的继承方式是 【9】 。
填空题若类B是类A的私有派生类,类C是类B的公有派生类,则类C{{U}} 【12】 {{/U}}访问基类A的公有成员。
填空题下列程序的招待结果是{{U}} 【14】 {{/U}}。
# include <iostream. h>
float temp;
float
float& b=fn2(5.0)
b=20;
cout<<temp<<end1;
}
填空题程序
#include"iostream.h"
void main( )
{
int i =10;
int j=5;
cout<<j+i++<<endl;
}
的结果为{{U}} 【7】 {{/U}}。
填空题在TestClass类的定义中,对赋值运算符=进行重载。请将画线处缺失的部分补充完整。______TestClass::operator=(const TestClass value=rhs.value; return *this; }
填空题以下程序的执行结果是______。
#include<iostream.h>
class Sample
{
int n;
public:
Sample(){}
Sample(int m){n+m;)
int&operator--(int)
{
n--
return n;
}
void disp () {cout<<"n= "<<n<<end1;}
}
void main ()
{
Sample s (10);
(s--) ++;
s.disp();
}
填空题多态具体体现运行和编译两个方面,在程序运行时的多态性通过继承和 ______ 来体现,而程序编译时多态性体现函数和运符的重载上。
填空题下面是一个栈类的模板,其中push函数将元素i压入栈顶,pop函数弹出栈顶元素。栈初始为空,top值为0,栈顶元素在stack[top-1]中,在下面横线处填上适当语句,完成栈类模板的定义。
template <class T>
class Tstack
{
enum{ size= 1000 };
T stack[size];
int top;
public:
Tstack():top(0){ }
void push(const T
}
T pop() {
if(top==0)exit(1); //栈空时终止运行
return{{U}} 【15】 {{/U}};
}
};
填空题假定一个一维数组的定义为“char a[8],b;”若把该数组最后一个元素赋值给b应该采取的表达式为:{{U}} 【7】 {{/U}}。
填空题 【14】 允许用户为类定义一种模式,使得类中的某些数据成员及某些成员函数的返回值能取任意类型。
填空题有以下程序: #include <iostream> using namespace std; class A public: virtual void show() cout<<"A"; ; class B : public A public: void show() cout << "B"; ; void display( A * obj ) obj-> show(); int main ( ) A demol; B demo2; display( display( return 0; 执行后的输出结果为 【13】 。
填空题下面程序的输出结果是
________
。
#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;
}
填空题面向对象的模型中,最基本的概念是对象和{{U}} [2] {{/U}}。
填空题已知一个函数的原型是: int fn((toubie x); 若要以5.27为实参调用该函数,应使用表达式______。
填空题在下面横线上填上适当的语句,完成程序。 #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; 在横线处应填入的语句是 【9】 。
填空题如果要在类的对象上使用运算符,除了运算符=和{{U}} {{U}} {{/U}} {{/U}}以外,其它的必须都要被重载。
填空题下列说明const chr* ptr;中,ptr应该是{{U}} {{U}} {{/U}} {{/U}}。
填空题对长度为10的线性表进行冒泡排序,最坏情况下需要比较的次数为{{U}} 【1】 {{/U}}。