填空题分析以下程序的执行结果{{U}} 【14】 {{/U}}。
#include<iostream.h>
class Sample
{
int x, y;
public:
Sample() {x=y=0; }
Sample(int a, int b) { x=a; y=b;}
~Sample()
{
if(x==y)
cout<<"x=y"<<end1;
else
cout<<"x!=y" <<end1;
}
void disp()
{
cout<<"x="<<x<<",y="<<y<<end1;
}
};
void main()
{
Sample s 1 (2,3);
s1. disp();
}
填空题有如下的程序:
#include <iostream>
#include <cstring>
using namespace std;
class rev{
char*s;
public:
rev(const char*s){
this->s=new char[strlen(s)+1];
strcpy(this->s,s);
}
rev(rev
for(int i=0;i<strlen(r.s);i++)s[i]=r.s[strlen(r.s)-1-i];
s[strlen(r.s)]=0;
}
~rev() {delete s;}
friend ostream
};
ostream1>=0;1--) os<<c.s[i];
return os;
}
int main() {
char *p="Hello,world!";
rev hay("Hay!");
cout<<rev(p)<<endl;
cout<<rev(hay);
return0;
}
执行上面的程序将输出______。
填空题C++在重载运算符中,如用成员函数重载一元运算符参数表中需要 【13】 个参数,如用友元函数重载一元运算符参数表中需要 【14】 个参数。
填空题假定输入28,那么程序运行的结果是 [9] 。 #include<iostream.h> void main() int n, i,k=0; cout<<“请输入整数”; cin>>n; for(i=1;i<n;i++) if(n%i= =0) k=k+i; if(n= =k)cout<<n<<“是完数/n”; else cout<<n<<“不是完数/n”;
填空题在用class定义一个类时,数据成员和成员函数的默认权限是{{U}} 【10】 {{/U}}。
填空题在一个图中,所有顶点的度数之和等于所有边数的 【2】 倍。
填空题在派生类中,对类对象成员,基类成员和非类对象成员的初始化程序是{{U}} 【7】 {{/U}}。
填空题请将下列类定义补充完整。 class Base(public:void fun()cout<<"Base::fun"<<endl;; class Derived:public Base public: void fun() ______ //显式调用基类的fun函数 cout<<"Derived::fun"<<endl; ;
填空题计算机技术中,为解决一个特定问题而采取的特定的有限的步骤称为{{U}} 【3】 {{/U}}。
填空题假定A为一个类,则语句A(A 为该类 函数的原型说明。
填空题如果表达式x=y*z中的“*”是作为成员函数重的运算符,采用运算符函数调用格式,该表达式还可以表示为______。
填空题C++本身没有定义I/O操作,但I/0操作包含在C++实现中。C++标准库iostream提供了基本的I/O类。I/O操作分别由类istream和工{{U}} 【11】 {{/U}}提供。
填空题下列程序编译错误,因为add函数返回值是一个引用,故对return后返回值的要求是{{U}} 【10】 {{/U}}。
#include<iostream. h>
int
}
void main( )
int i=3,j=19;
cout<<(add(i,j)+ =20)<<end1;
}
填空题树L中,度为1、2、3、4、5和6的节点个数为6、4、3、3、5、1,则L中叶子的个数是{{U}} 【2】 {{/U}}。
填空题以下程序的输出结果是 【10】 。 #include<iostream.h> unsigned frn(ullsigned num) unsi9ned k=1; dok*=num%10;num/=10; while(num); return k; void main() unsigned n=26; cout<<fun(n) <<endl;
填空题下面程序的运行结果是______。 #include <iostream> using namespace std; class count static int n; public: count() n++; static int test() for(int i=0;i<4;i++) n++; return n; ; int count::n=0; int main() cout<<count::test()<<""; count c1, c2; cout<<count::test()<<endl; return 0;
填空题在类中定义和实现的函数称为 【11】 。
填空题若已知a=10,b=20,则表达式!a<b的值为{{U}} 【7】 {{/U}}。
填空题C++语言的基本控制结构为顺序结构、选择结构和 【8】 。
填空题若有:
int x=25,y=14,z=19;
则在计算表达式x++<=25&&y--<=2&&++2<=18后,z的值为{{U}} [6] {{/U}}。
