填空题下面程序的输出结果是 【15】 。 #include<iostream.h> #include<math.h> class point double x; double y; public: point(doublea,d double B) x=a; y=b; friend double distance (point a,point B) ; ; double distance (point a,point B) return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); void main() point p1(1,2); point p2(5,2); cout<<distance(p1,p2)<<end1;
填空题在下面程序的横线处填上适当的语句,使该程序的输出为12。
#include <iostream>
using namespace std;
class Base
{
public:
int a;
Base(int i){ a=i; }
class Derived : public Base
{
int a;
public:
Derived(int x) : Base(x),b(x+1){}
void show()
{
______; //输出基类数据成员a的值
cout<<b<<endl;
}
};
int main ()
{
Derived d(1);
d.show();
return 0;
}
填空题以下函数模板max 的功能是返回数组a中最大元素的值。请将横线处缺失部分补充完整。
template <typename T>T max(T a[],int n)
{ T m=a[0];
for(int i=1 ;i<n;i++)
if(a[i]>m)
________
return m;
}
填空题动态多态性通过______实现。
填空题对于下面定义的类My Class,请在函数f()中添加对象成员把n的值修改为50。 class My Class public: My Class (int x)n=x; void SetNum (int n1)n=n1; private: int n; ; int f() My Class*ptr=new My Class(45); 【12】
填空题在E-R图中,矩形表示______。
填空题下列程序的执行结果为______。 #include<iostream.h> void main() cout<<fill('*'); cout<<width(10); cout<<"hello"<<end1;
填空题白盒测试法的覆盖标准有逻辑覆盖、循环覆盖和{{U}} 【4】 {{/U}}。
填空题在任何类中都有三种访问权限的数据成员,这三种权限是public、private和_______。
填空题在C++流类库中,根基类为 【9】 。
填空题在下面的程序的横线处填上适当的语句,使该程序的输出为12。 #include<iostream.h> using namespace std; class Base public: int a,b; Base(int i)a=i; ; class Derived:public Base int a; public: Derived(int x):Base(x),b(x+1); void show() ______;//输出基类数据成员a的值 cout<<b<<endl; ; int main() Derived d(1); d.show(); return 0;
填空题在最坏情况下,堆排序需要比较的次数为{{U}} 【2】 {{/U}}。
填空题类的静态成员的定义说明语句不能出现在类的外部,而且只能定义{{U}} {{U}} {{/U}} {{/U}}次。
填空题已知递归函数f的定义如下: int f(int n) if(n<=1)return 1; //递归结束情况 else return n*f(n-2);//递归) 则函数调用语句f(5)的返回值是______。
填空题语句cout<<setiosflagags(ios::showpos)<<125<<"/t"<<-125<<endl;的输出结果为{{U}} 【14】 {{/U}}。
填空题有如下复数类的声明,请补充完整。
class complex {
double real; //实部
double imag; //虚部
public:
complex(double x,double y) {
real=x;
imag=y;
}
complex operator +(complex c) { //重载加法运算符"+"
return complex({{U}} 【13】 {{/U}});
}
};
填空题下面程序的运行结果为 【13】 。 #include <iostream.h> void main() unsigned char value=127; int total=100; value++; total+=value; cout<<total<<end1; A) 227B) 100C) 127D) 27
填空题阅读下面程序: #include<iostream.h> void f(int n) int x(5); static int y(10); if(n>0) ++x; ++y; cout<<x<<","<<y<<endl; void main() int m(1); f(m), 则该程序的输出结果是 【14】 。
填空题C++语言中表示双精度浮点数的关键字是 【6】 。
填空题在一个派生类中,对基类成员、类对象成员和非类对象成员的初始化次序是先 【14】 ,后 【15】 ,最后为 【16】 。
