填空题使用VC++6.0打开考生文件夹下的源程序文件3.cpp,其中定义r用于表示个人基本信息的类PInfo,但类PInfo的定义并不完整。请按要求完成下列操作,将类PInfo的定义补充完成: (1)定义私有数据成员bloodType用于表示血型,血型为char型的数据。请在注释1之后添加适当的语句。 (2)完成构造函数的定义,要求具有默认值,默认值为身高175,体重70,血型A。请在注释2之后添加适当的语句。 (3)完成类PInfo外成员函数SetInfo的定义。请在注释3之后添加适当的语句。 (4)在主函数中调用成员函数SetInfo,把对象d2的3个私有数据成员分别设定为身高170,体重64,血型B。请在注释4之后添加适当的浯句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 试题程序: #include<iostream.h> class PInfo private: int height; int weight; //********1******** public: //********2******** :height(ht),weight(wt),bloodType(bt); PInfo(PInfo &h1):height(h1.height), weight(h1.weight),bloodType(h1.bloodType) int GetHeight() return height; int GetWeight() return weight; int GetBloodType() return bloodType; void SetInfo(int ht,int wt,char bt); void Display(); ; //********3******** height=ht; weight=wt; bloodType=bt; void Plnfo::Display() cout<<"HumanInfo:”; cout<<height<<"cm,"<<weight<<"Kg,BloodType"<<bloodType<<end1; void main() PInfo h1(169,61,'A'); PInfo h2; PInfo h3(h1); PInfo h4(h2); //********4******** h1.Display(); h2.Display(); h3.Display(); h4.Display();
填空题一个项目具有一个项目主管,一个项目主管可管理多个项目。则实体集“项目主管”与实体集“项目”的联系属于 【4】 的联系。
填空题若有定义:double a[3][5];那么数组a的最后一个元素是{{U}} 【9】 {{/U}}。
填空题程序 #include"iostream.h" void main() int i=10; int i=5; cout <<j+i++<<endl; 的结果为 【7】 。
填空题算法的基本特征是可行性、确定性、 和拥有足够的情报。
填空题试题源程序文件清单如下://proj1.cpp#include<iostream>usingnamespacestd;classMyClasspublic:MyClass():count(0)cout<<"Thisobjectis";//ERROR********found********voidInc()const(1)cout<<"no."<<++count<<endl;private://ERROR********found********intcount=0;(2);intmain()MyClass*obj=newMyClass;//ERROR********found*********obj.Inc();(3)return0:
填空题数据字典通常包括5个部分,即数据项、数据结构、数据流、 【2】 和处理过程。
填空题若有以下程序: #include<iostream> using namespace std; class TestClass 1 public: TestClass1() X=0; int x; ; class TestClass2:virtual public TestClass1 public: TestClass2() x=10; ; class TestClass3:virtual public TestClass 1 public: TestClass3() x=20; ; class TestClass4:public TestClass2, protected TestClass3 ; int main() TestClass4 obj; cout<<obj.x<<end1; return 0: 该程序运行后的输出结果是______。
填空题数据流图的类型有
________
和事务型。
填空题含有纯虚函数的类称为 【6】 。
填空题冒泡排序算法在最好的情况下的元素交换次数为
【1】
。
填空题以下程序中,fun 函数的功能是求 3 行 4 列二维数组每行元素中的最大值。请填空。
void fun(int,int,int(*)[4],int *);
main()
{ int a[3][4]={{12,41,36,28},{19,33,15,27},{3,27,19,1}},b[3],i;
fun(3,4,a,b);
for(i=0;i<3;i++) printf("%4d",b[i]);
printf("/n");
}
void fun(int m,int n,int ar[][4],int *br)
{ int i,j,x;
for(i=0;i
填空题下面是复数类complex的定义,其中重载的运算符“+”的功能是返回一个新的复数对象,其实部等于两个操作对象实部之和,其虚部等于两个操作对象虚部之和;请补充完整。 class complex double real; //实部 double imag; //虚部 public: complex(double r,double i):real(r),imag(i)j complex operator+(complex A) return complex(______); ;
填空题在C++流类库中,根基类为{{U}} 【9】 {{/U}}。
填空题在进行函数调用时,将把参数的{{U}} 【7】 {{/U}}传递给值参,把参数的{{U}} 【8】 {{/U}}传递给引用参数。
填空题阅读下面程序:
#include<iostream>
using namespace std;
long fib(int n)
{
if ( n > 2 )
return (fib(n-1)+fib(n-2));
else
return 2;
}
int main()
{
cout<<fib(3)<<end1;
return 0;
{
则该程序的输出结果应该是{{U}} 【8】 {{/U}}。
填空题设一棵二叉树的中序遍历结果为ABCDEFG,前序遍历结果为DBACFEG,则后序遍历结果为{{U}} 【1】 {{/U}}。
填空题C++语言中关键字运算符有new,delete和______。
填空题衡量模块独立性的两个重要度量标准是耦合性和内聚性。其中 【1】 用于度量模块间互相连接的紧密程度。
填空题下列函数用来在x数组中插入a值,x数组中的数据已由小到大顺序存放,指针n所指内存单元中存放数组中数据的个数,插入后数组中的数据仍有序。请将横线处的程序补充完整。
void fun(char* x,char a,int* n)
{
int k,p=0;
x[*n]=a;
while(a>x[p]) p++;
for(k=*n;k>p;k--) x[k]=______;
x[p]=a;
++*n;
}
