填空题在单链表上难以实现的排序方法有希尔排序、{{U}} 【4】 {{/U}}和堆排序。
填空题重新定义标识符的作用域规定是外层变量被隐藏,______变量是可见的。
填空题下列程序的输出结果是______。 #include <iostream.h> void main() int i(1),j(2),k(3),a(10); if(!i) a--; else if(j) if(k) a=5; else a=6; a++; cout<<a<<endl; if(i<j) if(i!=3) if(!k) a=1; else if(k) a=5; a+=2; cout<<a<<endl;
填空题 【12】 是一系列相关函数的模型或样板,这些函数的 【13】 形式相同,只是所针对的 【14】 不同。
填空题以下程序的输出结果是 [10] 。 #include<iostream. h> void main() int *p; p=new int; *p=200; cout<<*p; delete p;
填空题常数据成员和静态数据成员在使用前共同的要求是要进行 【11】 。
填空题下列程序的运行结果是 【9】 。#include<iomanip. h>int Func(int * a, int n) int s=1; for(int i=0;i<n; i++) s*= * a++; return s;void main( ) int a[]=1,2,3,4,5,6,7,8); int b=Func(a,6)+Fnnc( cout<<"b= "<<b<<end1;
填空题数学表达式写成c++语言的表达式为{{U}}【6】{{/U}}。
填空题下面程序的打印结果是 【11】 。 #include <iostream> using namespace std; class Base public: Base(int x) a=x; void show() cout<<a; private: int a; ; class Derived : public Base public: Derived(int i) :Base(i+1) ,b(i) void show() cout<<b; private: int b; ; int main ( ) Base b(5) , *pb; Derived d(1); pb= pb->show(); return 0;
填空题将关键字const写在函数头之后,函数体之前,说明该函数是一个const成员函数。此时const不是指定函数的返回值,而是修饰{{U}} 【10】 {{/U}}指针。
填空题带一个long类型参数的流成员函数_____按参数值设置flags状态变量,并返回以前设置的标志值。
填空题已知f1(int)是类A的公有成员函数,并将指针p定义为可以指向函数f1的指针类型,则可以实现让p是指向成员函数f1()的指针的语句为______。
填空题若从键盘输入70,则以下程序输出的结果是{{U}} 【8】 {{/U}}。
#include<iostream.h>
void main()
{
int a; cin>>a;
if(a>50) cout<<a;
if(a>40) cout<<a;
if(a>30) cout<<a;
}
填空题使用VC++6.0打开考生文件夹下的源程序文件3.cpp,其中定义了用于表示雇员的Employee类,但类Employee的定义并不完整。请按要求完成下列操作,将类TC的定义补充完整。 (1)定义私有数据成员name、street、city、zipcode和age分别用于表示姓名、街道、城市、邮编、年龄,除年龄是整型外,其余都是char型的数据。请在注释1之后添加适当的语句。 (2)完成默认构造函数TC的定义,使其把参数传递给私有数据成员name、street、city、zipcode和age。请在注释2之后添加适当的语句。 (3)完成成员函数alterName(char *newName)的定义。请在注释3之后添加适当的语句。 (4)完成成员函数IsEqual(char *ename)的定义,实现当name相等时返回真,否则返回假的功能。请在注释4之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 试题程序: #include<iostream.h> #include<string.h> #define MAXLEN 20 class TC private: //********1******** int age; public: TC(char *newName,char *newStreet,char *newCt,char*newZp,int newAge); void alterName(char *newName); void display(); bool IsEqual(char *ename); ; TC::TC(char *newName,char *newStreet,char *newCt,char *newZp,int newAge) //********2******** age=newAge; void TC::alterName(char *newName) //********3******** bool TC::IsEqual(char *ename) //********4******** void TC::display() cout<<name<<""<<street<<""; cout<<city<<""<<zipcode<<""<<age<<end1; void main(void) TC employee[4]= TC("张三","海淀区复兴路1号","北京","000001",18), TC("李四","海淀区复兴路2号","北京","000002",19), TC("王五","海淀区复兴路3号","北京","000003",20), TC("赵六","海淀区复兴路4号","北京","000004",21) ; for(int i=0;i<4;i++) employee[i].display(); cout<<"/n修改/"李四/"的名字为/"李小四/"/n"<<end1; for(int j=0;j<4;j++) if(employee[j].IsEqual("李四")) employee[j].alterName("李小四"); employee[j].display(); break;
填空题如果不使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员。下列程序没有使用多态机制,其输出结果是{{U}} 【13】 {{/U}}。
#include <iostream>
using namespace std;
class Base {
public:
void print () {ctout << 'B'; }
};
class Derived; public Base {
public:
void print () {cout <<'D'; }
};
int main()
{
Derived* pd= new Derived();
Base* pb = pd;
pb->print();
pd->print();
delete pd;
return ();
}
填空题下列for语句的循环次数为【8】。 for(int a=0,b=1;b&&a
填空题使用VC++6.0打开考生文件夹下的源程序文件3.cpp,其中定义了用于表示矩形的CRect类,但类CRect的定义并不完整。请按要求完成下列操作,将类CRect的定义补充完整。 (1)定义私有数据成员leftPoint、topPoint、rightPoint、bottomPoint,分别用于表示矩形左上角及右下角的点的坐标,它们都是double型的数据。请在注释1之后添加适当的语句。 (2)完成默认构造函数CRect的定义,指定默认实参为0,它们都是double型的数据。请在注释2之后添加适当的语句。 (3)定义函数体为空的析构函数。请在注释3之后添加适当的语句。 (4)在main函数中定义CRect类的实例rect2,并把reetl的值赋给rect2。请在注释4之后添加适当的语句。 注意:除在指定位置添加语句之外,不要改动程序中的其他内容。 试题程序: #include<iostream.h> class CRect private: //********1******** public: //********2******** //********3******** void SetPoints(double,double,double,double); void SetLeftPoint(double m)leftPoint=m; void SetRightPoint(double m)rightPoint=m; void SetTopPoint(double m)topPoint=m; void SetBottomPoint(double m)hottomPoint=m; void Display(); ; CRect::CRect(double l,double t,double r,double b) leftPoint=1;topPoint=t; rightPoint=r;bottomPoint=b; void CRect::SetPoints(double l,double t,double r,double b) leftPoint=l;topPoint=t; rightPoint=r;bottomPoint=b; void CRect::Display() cout<<"left-top point is("<<leftPoint<<","<<topPoint<<")"<<'n'; cout<<"right-bottom point is("<<rightPoint<<","<<bottomPoint<<")"<<'/n'; void main() CRect rect0; rect0.Display(); rect0.SetPoints(20,20.6,30,40); rect0.Display(); CRect rect1(0,0,150,150); rect1.SetTopPoint(10.5); rect1.SetLeftPoint(10.5); //********4******** rect2.Display();
填空题下列程序的输出结果为
________
。
#include <iostream. h>
void main()
{
char a[]="abcdabcabfgacd";
int i1=0,i2=0,i=0;
while (a[i])
{
if (a[i]=="a") i1++;
if (a[i]=="q") i2++;
i++;
}
cout<<i1<<""<<i2<<end1;
}
填空题有如下程序: #include <iostream> using namespace std; class Con char ID; public: Con( ):ID('A')cout<<1; Con(char ID) :ID(ID) eout<<2; Con(ConC) :ID(C.getID( ))cout<<3; char getID( )constreturn ID; ; void show(Con e)cout<<e.getID( ); int main( ) Con cl; show(c1); Con c2('B'); show(c2); return 0; 程序的输出结果是______。
填空题用树形结构表示实体类型及实体间联系的数据模型称为 。