填空题分析以下程序的执行结果 【14】 。#include<iostream.h>class Sampleint x, y;public:Sample() x=y=0; Sample(int a, int b) x=a; y=b;~Sample()if(x==y)cout<<"x=y"<<end1;elsecout<<"x!=y" <<end1;void disp()cout<<"x="<<x<<",y="<<y<<end1;;void main()Sample s 1 (2,3);s1. disp();
填空题软件生命周期可分为多个阶段。一般分为定义阶段、开发阶段和维护阶段。编码和测试属于{{U}} 【4】 {{/U}}阶段。
填空题程序的结果为{{U}} 【14】 {{/U}}。
#include"iostream.h"
template<typename T>
T total(T*data)
{
T s=0;
while(* data)
{
s+=*data++;
}
return s;
}
int main( )
{ int x[ ]={ 2,4,6,8,0,12,14,16,18 };
cout<<total(x);
return 0;
cout<<endl;}
填空题下面程序的输出结果是{{U}} 【15】 {{/U}}。
#include <iostream.h>
#include <math.h>
class point
{
double x;
double y;
public:
point(double a, 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;
}
填空题使用函数模板的方法是先说明函数模板,然后实例化成相应的 ______ 进行调用执行。
填空题关系模型的四种基本操作为插入、删除、修改和 【4】 。
填空题对于派生类的构造函数,在定义对象时构造函数的执行顺序为:先执行 [14] 。再执行成员对象的构造函数,后执行派生类本身的构造函数。
填空题阅读下面程序:
#include <iostream.h>
int fun2(int m)
{
if(m%3==0)
return 1;
else
return 0;
}
void fun1(int m, int
for (i=1; i<m; i++)
if(fun2(i))
S=S*i;
}
void main()
{
int n=9, s=2;
fun1(n, s);
cout<<s<<end1;
}
该程序的运行结果是
________
。
填空题数据的逻辑结构有线性结构和{{U}} 【1】 {{/U}}两大类。
填空题经常和一个运算符连用,构成一个运算符函数名的C++关键字是 【15】 。
填空题数据管理技术发展过程经过人工管理、文件系统和数据库系统3个阶段,其中数据独立性最高的是______阶段。
填空题下列程序的输出结果是______。 #include <iostream> #include <cstring> using namespace std; void fun(const char*S,char &C) e=s[strlen(s)/2]; int main( ) char str[ ]="ABCDE"; char ch=str[1]; fun(str,ch); cout<<ch; return 0;
填空题如下类定义中包含了构造函数和拷贝构造函数的原型声明,请在横线处填写正确的内容,使拷贝构造函数的声明完整。 class myClass private: int data; public: myClass(int value); //构造函数 myClass(const______anotherObject); //拷贝构造函数
填空题对于派生类的构造函数,在定义对象时构造函数的执行顺序为:先执行调用______的构造函数,再执行调用子对象类的构造函数,最后执行派生类的构造函数体中的内容。
填空题若有如下程序段:
#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}} 【10】 {{/U}}。
填空题利用表达式a[i]可以访问int型数组a中下标为i的元素。在执行了语句int*p=a;后,利用指针p也可访问该元素,相应的表达式是______。
填空题假定动态分配一个类型为Worker的具有n个元素的数组,并由P指向这个动态数组,如果要释放这个数组,则使用的语句为 【13】 。
填空题有以下程序: #include<iostream> #include<fstream> using namespace std; int main() fstream file; file.open("abc.txt", ios :: in); if ( !file ) cout<<"Can not open abc.txt"<<end1; abort(); char buf[ 80 ]; int i = 0; while (!file.eof()) file.getline(buf,80); i++; cout<<"Lines :"<<i<<end1; file.close(); return 0; 程序实现的功能是 【15】 。
填空题程序文件的编译错误分为______和______两类。
填空题在面向对象方法中,类之间共享属性和操作的机制称为{{U}} 【2】{{/U}}。