填空题将x+y中的+运算符用友元函数重载应写为{{U}} 【11】 {{/U}}。
填空题若有“intx=15, y=20;”,则执行表达式y-=x++后,表达式x+y的值为______。
填空题用递归思想写出的程序往往十分简洁、易懂,但执行时需要的______很多。
填空题C++中每个类都有一个隐含的______指针。
填空题在下面函数的横线处填上适当的内容使该函数能够利用递归方法求解字符串str的长度(不得使用系统提供的字符串处理函数)。
int GetLen(char *str
{
if ({{U}} 【6】 {{/U}}) return {{U}}【17】 {{/U}};
else return 1+GetLen (str+1);
}
填空题有如下程序:
#include<iostream>
using namespace std;
class Pet{
char name[10];
public:
Pet(char*name){strcpy(this->name,name);}
const char*getName()const {return name;}
virtual void call()const=0;
};
class Dog:public Pet{
public:
Dog(char*name):Pet(name){}
void call()const{cout<<"汪汪叫":}
};
class Cat:public Pet{
public:
Cat(char*name):Pet(name){}
void call()const{cout<<"喵喵叫";}
};
int main(){
Pet*pet1=new Dog("哈克"),*pet2=new Cat("吉米");
cout<<pet1->getName();pet1->call();cout<<end1;
cout<<pet2->getName();pet2->call();cout<<end1;
return 0;
}
程序的输出结果是______。
填空题数据的逻辑结构是从逻辑关系上描述数据,它与数据的{{U}} 【2】 {{/U}}结构无关。
填空题有如下程序:
#include <iostream>
using namespace std;
class AA
{
public:
virtual void f()
{
cout<<"AA";
}
};
class BB: public AA
{
public:
BB()
{
cout<<"BB";
};
class CC: public BB
{
public:
virtual void f()
{
BB::f();
cout<<"CC";
}
};
int main()
{
AA aa,*p; BB bb; CC cc;
p=
P->f();
return 0;
}
运行后的输出结果{{U}} 【15】 {{/U}}。
填空题在下面程序的横线处填上适当的语句,使该程序的输出为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+l){}
void show()
{
{{U}} 【11】 {{/U}};∥输出基类数据成员a的值。
cout<<b<<end1;
}
};
int main()
{
Derived d(1);
d.show();
return 0;
}
填空题若有以下程序: #include <iostream> using namespace std; int main() char a; a='H'-'A'+'0'; cout<<a<<end1; return 0; 执行后输出的结果是 【6】 。
填空题下列程序的运行结果是______。 #include<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);
填空题下列程序的运行结果为{{U}} 【14】 {{/U}}。
#include <iostream. h>
class myclass
{
private:
int a, b, c;
public:
void fun()
{
int a;
a=10;
this->,a=5;
b=6;
this->c=7;
cout<<"a="<<a<<",this->a="<<this->a<<endl;
}
};
void main()
{
myclass obj1;
obj1.fun()
}
填空题软件测试的目的是尽可能发现软件中错误,通常{{U}} 【4】 {{/U}}是在代码编写阶段可进行的测试,它是整个测试工作的基础。
填空题对于下面定义的类MyClass,请在函数f( )中添加对象成员把n的值修改为50。
class MyClass
{
public:
MyClass(intx) {n=x;}
void SetNum(int nl) {n=nl;}
private:
int n;
};
int f( )
{
MyClass * ptr=new MyClass(45) ;
{{U}} {{/U}}
}
填空题若有如下程序段:
#include <iostream>
using namespace std;
int main()
{
char *p="abcdefgh",*r;
long *q;
q=(long *)p;q++;
r=(char *)q;
cout<<r<<end1;
return 0;
}
该程序的输出结果是{{U}} 【8】 {{/U}}。
填空题冒泡排序在最好情况下时间复杂度为{{U}} [3] {{/U}}。
填空题有如下程序:
#include<iostream>
using namespace std;
int fun1(int x){return++x;}
int fun2(int }
int main(){
int x=1,y=2;
y=fun1(fun2(x));
cout<<x<<","<<y;
return 0;
}
程序的输出结果是______
填空题有以下程序
#include <iostream>
using namespace std;
class Base
{
int a;
public:
Base(int x) { a=x; }
void show() { cout<<a; }
class Derived: public Base
{
int b;
public:
Defived(int i):Base(i+ 1 ),b(i) {}
void show() { cout<<b; }
};
int main()
{
Base b(5),*pb;
Derived d(1);
pb=
pb->show();
return 0;
}
运行后的打印结果是{{U}} 【13】 {{/U}}。
填空题在下列的程序的横线处填上适当的语句,使该程序的输出为12。 #include<iostream> using namespace std; class TestClass public: int a,b; TestClass(int i,int j) a=i; b=j; ; class TestClass1:public TestClass int a; public: TestClass1(int x):TestClass(x,x+1) void show() ______;//输出基类数据成员a的值? cout<<b<<endl; ; int main() TestClass1 d(1); d.show(); return 0;
填空题重载的运算符保持其原有的 、优先级和结合性不变。