填空题下列程序的输出结果为:
Object id=0
Object id=1
请将程序补充完整。
#include <iostream>
using namespace std;
class Point
{
public:
Point(int xx=0,int yy=0) {X=xx;Y=yy;countP++;}
~Point() {countP--;}
int GetX() {return X;}
int GetY() {return Y;}
static void GetC0 {cout <<"Objectid="<<countp<<end1;}
private:
int X,Y;
static int countP;
};
{{U}} 【9】 {{/U}}//静态数据成员的初始化
int main()
{
Point:: GetC();
Point A(4,5);
A.GetC();
return 0;
}
填空题C++语言中的每条基本语句以 【19】 作为结束符,每条复合语句以 【20】 作为结束符。
填空题流成员函数_______返回当前流的状态。
填空题C++中,派生类继承了基类的全部数据成员和除{{U}} {{U}} {{/U}} {{/U}}之外的全部函数成员。
填空题在算法的5个特性中,算法必须能在执行有限个步骤之后终止,指的是算法的 【2】 性。
填空题软件开发过程主要分为需求分析、设计、编码与测试四个阶段,其中{{U}} 【3】 {{/U}}产生“软件需求规格说明书”。
填空题若把类B定义为类A的友元类,则应在类A中加入定义语句 【11】 。
填空题如下程序执行后的输出结果是 【14】 。 #include <iostream> using namespace std; class Base public: Base(int x,int y) a=x; b=y; void Show() cout<<"Base: "<<a<< ',' <<b<<" "; private: int a,b; ; class Derived : public Base public: Derived(int x, int y, int z) : Base(x,y),c(z) void Show() cout<<"Derived:"<<c<<end1; private: int c; ; int main() Base b(100,100),*pb; Derived d(10,20,30); pb= pb->Show(); pb= pb->Show(); return 0;
填空题下列程序的运行结果是______。 #included<iostream.h> class Sample int a; public: Sample(int aa=0)a=aa; ~Sample()cout<<"Sample="<<a<<''; ; class Derived:public Sample int b; public: Derived(int aa=0,int bb=0):Sample(aa)b=bb; ~Derived()cout<<"Derived="<<b<<''; ; void main() Derived d1(9);
填空题如果类Alpha继承了类Beta,则类Alpha称为派生类,类Beta称为{{U}} 【9】 {{/U}}类。
填空题程序的输出结果是 【14】 。 #include <iostream> using namespace std; class A int x; public: A(int x=1):x(x)cout<<x; ; void main() A a,b(2),c(3);
填空题若有如下程序段:
#include<iostream>
using namespace std;
int main()
{
char *p="abcdefgh",*r;
long *q;
q=(long*)p;q++;
r=(char*)q;
cout<<r<<endl;
return 0;
}
该程序的输出结果是{{U}} {{U}} {{/U}} {{/U}}。
填空题在有序列表(3,6,8,10,12,15,16,18,21,25,30)中,用二分法查找关键码值 12,所需的关键码比较次数为{{U}} 【3】 {{/U}}。
填空题下列程序的输出结果是
________
。
#include <iostream>
#include <cstring>
using namespace std;
void fun(const char *s, char }
int main()
{
char str[]="ABCDE";
char ch=str[1];
fun(str, ch);
cout<<ch;
return 0;
}
填空题下面是复数类complex的定义,其中重载的运算符“+”的功能是返回一个新的复数对象,其实部等于两个操作对象实部之和,其虚部等于两个操作对象虚部之和;请补充完整:class complexdouble real; //实部double imag; //虚部public:complex( double r, double i):real(r),imag(i)complex operator + (complex a) return complex( 【13】 );;
填空题设有下定义的语句:
int a[3][2]={10,20,30,40,50,60};
int b[3][2]={10,20,30,40,50,60};
则a[1][1]*b[2][1]={{U}} {{U}} {{/U}} {{/U}}。
填空题写出执行完下列代码段之后指定变量的值: boo1 x=true,y=false,z=false; x=x y=x‖y z=!(x!=y)‖(y==z), 则 x=false, y=false, z=______。
填空题下面程序的结果为 【7】 。 #include<iostream.h> void main( ) int a=1,b=2; bool c=1; if((a>b) ||c) cout<<"true"<< end1; else cout<<"false"<<end1;
填空题下列程序的输出结果为______。 #include<iostream.h> void Func(char ch) switch(ch) case 'A':case 'a': cout<<"优秀"<<endl; case 'B':case 'b': cout<<"良好"<<endl; break; case 'C':case 'c': cout<<"及格"<<endl; break; default: cout<<"不及格"<<endl; void main( ) char ch1='b' Func(ch1); Func('A');
填空题根据输出结果填空完成下面程序。 #include<iostream.h> class Test private: static int val; int a; public: static int func(); void sfunc(Test &r); ; ______//初始化静态变量val int Test::func() return val++; void Test::sfunc(Test &r) r.a=125; cout<<"Result3="<<r.a; void main() cout<<"Resuh1="<<Test::func()<<end1; Test A; cout<<"Resuh2="<<A.func()<<end1; A.sfunc(A); 输出结果为 Result1=201 Result2=202 Resuh3=125
