logo资料库

2006年4月全国计算机二级C++考试真题及答案.doc

第1页 / 共12页
第2页 / 共12页
第3页 / 共12页
第4页 / 共12页
第5页 / 共12页
第6页 / 共12页
第7页 / 共12页
第8页 / 共12页
资料共12页,剩余部分请下载后查看
2006 年 4 月全国计算机二级 C++考试真题及答案 (考试时间 90 分钟,满分 100 分) B.逐步求精 D.可复用 B.内聚度 D.数据传输特性 一、选择题((1)~(35)每小题 2 分,共 70 分) 下列各题 A)、B)、C)、D)四个选项中,只有 一个选项是正确的,请将正确选项涂。 写在答题卡相应位置上,答在试卷上不得分。 (1)下列选项不属于结构化程序设计方法的是 A.自顶向下 C.模块化 (2)两个或两个以上模块之间关联的紧密程度称为 A.耦合度 C.复杂度 (3)下列叙述中正确的是 A.软件测试应该由程序开发者来完成 B.程序经调试后一般不需要再测试 C.软件维护只包括对程序代码的维护 D.以上三种说法都不对 (4)按照“后进先出”原则组织数据的数据结构是 A.队列 C.双向链表 (5)下列叙述中正确的是 A.线性链表是线性表的链式存储结构 B.栈与队列是非线性结构 C.双向链表是非线性结构 D.只有根结点的二叉树是线性结构 (6)对如下二叉树,进行后序遍历的结果为 B.栈 D.二叉树 B.DBEAFC D.DEBFCA A.ABCDEF C.ABDECF (7)在深度为 7 的满二叉树中,叶子结点的个数为 A.32 (8)“商品”与“顾客”两个实体集之间的联系一般是 A.一对一 C.多对一 (9)在 E-R 图中,用来表示实体的图形是 A.矩形 (10)数据库 DB、数据库系统 DBS、数据库管理系统 DBMS 之间的关系是 A.DB 包含 DBS 和 DBMS B.DBMS 包含 DB 和 DBS B.一对多 D.多对多 B.椭圆形 C.菱形 B.31 C.64 D.63 D.三角形
C.DBS 包含 DB 和 DBMS D.没有任何关系 (11)下列关于 C++函数的说明中,正确的是 A.内联函数就是定义在另一个函数体内部的函数 B.函数体的最后一条语句必须是 return 语句 C.标准 C++要求在调用一个函数之前,必须先声明其原型 D.编译器会根据函数的返回值类型和参数表来区分函数的不同重载形式 (12)由于常对象不能被更新,因此 A.通过常对象只能调用它的常成员函数 B.通过常对象只能调用静态成员函数 C.常对象的成员都是常成员 D.通过常对象可以调用任何不改变对象值的成员函数 (13)下列关于虚函数的说明中,正确的是 A.从虚基类继承的函数都是虚函数 B.虚函数不得是静态成员函数 C.只能通过指针或引用调用虚函数 D.抽象类中的成员函数都是虚函数 (14)运算符重载是对已有的运算符赋予多重含义,因此 A.可以对基本类型(如 int 类型)的数据,重新定义“+”运算符的含义 B.可以改变一个已有运算符的优先级和操作数个数 C.只能重载 C++中已经有的运算符,不能定义新运算符 D.C++中已经有的所有运算符都可以重载 (15)模板对类型的参数化提供了很好的支持,因此 A.类模板的主要作用是生成抽象类 B.类模板实例化时,编译器将根据给出的模板实参生成一个类 C.在类模板中的数据成员都具有同样类型 D.类模板中的成员函数都没有返回值 (16)下列关于 C++流的说明中,正确的是 A.与键盘、屏幕、打印机和通信端口的交互都可以通过流类来实现 B.从流中获取数据的操作称为插入操作,向流中添加数据的操作称为提取操作 C.cin 是一个预定义的输入流类 D.输出流有一个名为 open 的成员函数,其作用是生成一个新的流对象 (17)下列符号中可以用作 C++标识符的是 B.foo~bar A._radius C.else D.3room (18)下列语句中,错误的是 A.const int buffer=256; B.const int temp; C.const double *point; D.const double *rt =new double(5.5); (19)有如下程序: int x=3; do{ x -= 2; 一次,他在核实数据时,认为部分数据需要重新测量,但项目部的车都被派出去了。belimitedtonomorethan2daysofwork,materialdepositedinspecialinsulatedcontainers,materialhandlingtogentlyandmakeuseofthermalinsulationmaterialinwindproof,waterproof,moisture-proofmeasure.6.2thermaldesignoptimizationforhigh-temperaturespecialthermalinsulationforpipingsupportandhangerdesign,reducedheatdissipationofthehangers,ensurethatthewalldoesnotoverheat.Small-diameterpiping,thermalinstrumentlayoutandpositioningofsupportandhangerdesigntakefullyintoaccounttheexpansionspaceandinsulationthickness.Large-diameterpipesafterheatpreservationplasteringconstructionofvalves,turbine,checkingsmoothsurface,hightemperaturepowderpaintfullydryafter.Protectivecoveringsforelectricequipmentinsulationboardsdesignedwithpressureplate,whenorderingaccordingtotheinstallationdiagram,modelspecificationspublishingorder,ensurewheninstallingcornersneat,uniformappearance,reducetheamountofon-sitemachining.Beforevalves,flangeinsulationshellconstruction,besuretomakeaunifiedmodel,allvalves,flanges,insulationcoverunified,tidyandbeautiful.Whenfourpartssuchaspipes,boilerinsulation,mustdofirstarticleinspection,proofofdesignandconstructionmethods,technologycanmeetthetechnologicalrequirements,beforeextensiveconstruction.Boilersteelbeams,dooropeningboxesdesignedwithinsulationgaskets,flangecannotbeoblique,evenfastened.Backintotheslopeofthetubingduringinstallationpayattentiontothepiping,oilstationisalowpoint.Refuelingmustbecontrolledwhencastingmaterialparts,selectlowthermalconductivitymaterialsasfaraspossible,ensurethatthesepartsdonotoverheat.6.3qualitydefectsofinsulationtechnologymanagementoptimizationofconstructionprocessanddevelopareasonableduration,regionaltransferofstrictly
cout< using namespace std; int main() { int *p; C. l-2 D.死循环 *p = 9; cout << "The value at p: " << *p; return 0; } 编译运行程序将出现的情况是 A.够编译时出现语法错误,不能生成可执行文件 B.运行时一定输出:The value at p: 9 C.运行时一定输出:The value at p: *9 D.运行时有可能出错 (21)有如下程序: #include using namespace std; int main() { void function(double val); double val; function(val); cout<
D.④ B.② friend void show(AA aa) const {cout< //④ }; 其中的四个函数定义中正确的是 A.① (23)有如下程序: #include using namespace std; class Base { public: C.③ void fun() { cout<<"Base::fun"<fun() (24)下面是重载为非成员函数的运算符函数原型,其中错误的是 A.Fraction operator + (Fraction, Fraction); B.Fraction operator - (Fraction); C.Fraction& operator = (Fraction&, Fraction); D.Fraction& operator += (Fraction&, Fraction); (25)有如下函数模板: template T cast(U u) { 其功能是将 U 类型数据转换为 T 类型数据。已知 i 为 int 型变量,下列对模板函数 cast 的 调用中正确的是 A . cast(i); C.cast(i); (26)若磁盘上已存在某个文本文件,其全路径文件名为 d:\ncre\test.txt,下列语句中不 B . cast<>(i); B.Base::fun() D.fun(); return u; } D.cast (i); 一次,他在核实数据时,认为部分数据需要重新测量,但项目部的车都被派出去了。belimitedtonomorethan2daysofwork,materialdepositedinspecialinsulatedcontainers,materialhandlingtogentlyandmakeuseofthermalinsulationmaterialinwindproof,waterproof,moisture-proofmeasure.6.2thermaldesignoptimizationforhigh-temperaturespecialthermalinsulationforpipingsupportandhangerdesign,reducedheatdissipationofthehangers,ensurethatthewalldoesnotoverheat.Small-diameterpiping,thermalinstrumentlayoutandpositioningofsupportandhangerdesigntakefullyintoaccounttheexpansionspaceandinsulationthickness.Large-diameterpipesafterheatpreservationplasteringconstructionofvalves,turbine,checkingsmoothsurface,hightemperaturepowderpaintfullydryafter.Protectivecoveringsforelectricequipmentinsulationboardsdesignedwithpressureplate,whenorderingaccordingtotheinstallationdiagram,modelspecificationspublishingorder,ensurewheninstallingcornersneat,uniformappearance,reducetheamountofon-sitemachining.Beforevalves,flangeinsulationshellconstruction,besuretomakeaunifiedmodel,allvalves,flanges,insulationcoverunified,tidyandbeautiful.Whenfourpartssuchaspipes,boilerinsulation,mustdofirstarticleinspection,proofofdesignandconstructionmethods,technologycanmeetthetechnologicalrequirements,beforeextensiveconstruction.Boilersteelbeams,dooropeningboxesdesignedwithinsulationgaskets,flangecannotbeoblique,evenfastened.Backintotheslopeofthetubingduringinstallationpayattentiontothepiping,oilstationisalowpoint.Refuelingmustbecontrolledwhencastingmaterialparts,selectlowthermalconductivitymaterialsasfaraspossible,ensurethatthesepartsdonotoverheat.6.3qualitydefectsofinsulationtechnologymanagementoptimizationofconstructionprocessanddevelopareasonableduration,regionaltransferofstrictly
C.③ D.④ 能打开该文件的是 A.ifstream file("d:\ncre\test.txt"); B.ifstream file("d:\ncre\test.txt"); C.ifstream file; file.open("d:\ncre\test.txt"); D.ifstream* pFile=new ifstream("d:\ncre\test.txt"); (27)有如下类定义: class Foo { public: Foo(int v):value(v){} //① ~Foo(){} //② private: Foo(){} //③ int value = 0; //④ }; 其中存在语法错误的行是 B.② A.① (28)有如下类定义: class Point { int x_, y_; public: Point():x_(0), y_(0){} Point(int x, int y = 0):x_(x),y_(y){} }; 若执行语句 Point a(2), b[3], *c[4]; 则 Point 类的构造函数被调用的次数是 A.2 次 (29)有如下类定义: class Test { public: Test(){ a = 0; c = 0;} //① int f(int a)const{this->a = a;} //② static int g(){return a;} //③ void h(int B.{Test::b = b;}; //④ private: int a; static int b; const int c; }; int Test::b = 0; B.3 次 C.4 次 一次,他在核实数据时,认为部分数据需要重新测量,但项目部的车都被派出去了。belimitedtonomorethan2daysofwork,materialdepositedinspecialinsulatedcontainers,materialhandlingtogentlyandmakeuseofthermalinsulationmaterialinwindproof,waterproof,moisture-proofmeasure.6.2thermaldesignoptimizationforhigh-temperaturespecialthermalinsulationforpipingsupportandhangerdesign,reducedheatdissipationofthehangers,ensurethatthewalldoesnotoverheat.Small-diameterpiping,thermalinstrumentlayoutandpositioningofsupportandhangerdesigntakefullyintoaccounttheexpansionspaceandinsulationthickness.Large-diameterpipesafterheatpreservationplasteringconstructionofvalves,turbine,checkingsmoothsurface,hightemperaturepowderpaintfullydryafter.Protectivecoveringsforelectricequipmentinsulationboardsdesignedwithpressureplate,whenorderingaccordingtotheinstallationdiagram,modelspecificationspublishingorder,ensurewheninstallingcornersneat,uniformappearance,reducetheamountofon-sitemachining.Beforevalves,flangeinsulationshellconstruction,besuretomakeaunifiedmodel,allvalves,flanges,insulationcoverunified,tidyandbeautiful.Whenfourpartssuchaspipes,boilerinsulation,mustdofirstarticleinspection,proofofdesignandconstructionmethods,technologycanmeetthetechnologicalrequirements,beforeextensiveconstruction.Boilersteelbeams,dooropeningboxesdesignedwithinsulationgaskets,flangecannotbeoblique,evenfastened.Backintotheslopeofthetubingduringinstallationpayattentiontothepiping,oilstationisalowpoint.Refuelingmustbecontrolledwhencastingmaterialparts,selectlowthermalconductivitymaterialsasfaraspossible,ensurethatthesepartsdonotoverheat.6.3qualitydefectsofinsulationtechnologymanagementoptimizationofconstructionprocessanddevelopareasonableduration,regionaltransferofstrictly5 D.5 次
C.③ D.④ B.ABA~B~A~A D.ABA~A~B~A B.② 在标注号码的行中,能被正确编译的是 A.① (30)有如下程序: #include using namespace std; class A { public: A(){cout<<"A";} ~A(){cout<<"~A";} }; class B:public A { A* p; public: B(){cout<<"B"; p = new A();} ~B(){cout<<"~B"; delete p;} }; int main() { B obj; return 0; } 执行这个程序的输出结果是 A.BAA~A~B~A C.BAA~B~A~A (31)有如下程序: #include using namespace std; class Base { private: void funl() const{cout<<"funl";} protected: void fun2() const{cout<<"fun2";} public: void fun3() const{cout<<"fun3";} }; class Derived:protected Base { public: void fun4() const{cout<<"fun4";} }; int main() 一次,他在核实数据时,认为部分数据需要重新测量,但项目部的车都被派出去了。belimitedtonomorethan2daysofwork,materialdepositedinspecialinsulatedcontainers,materialhandlingtogentlyandmakeuseofthermalinsulationmaterialinwindproof,waterproof,moisture-proofmeasure.6.2thermaldesignoptimizationforhigh-temperaturespecialthermalinsulationforpipingsupportandhangerdesign,reducedheatdissipationofthehangers,ensurethatthewalldoesnotoverheat.Small-diameterpiping,thermalinstrumentlayoutandpositioningofsupportandhangerdesigntakefullyintoaccounttheexpansionspaceandinsulationthickness.Large-diameterpipesafterheatpreservationplasteringconstructionofvalves,turbine,checkingsmoothsurface,hightemperaturepowderpaintfullydryafter.Protectivecoveringsforelectricequipmentinsulationboardsdesignedwithpressureplate,whenorderingaccordingtotheinstallationdiagram,modelspecificationspublishingorder,ensurewheninstallingcornersneat,uniformappearance,reducetheamountofon-sitemachining.Beforevalves,flangeinsulationshellconstruction,besuretomakeaunifiedmodel,allvalves,flanges,insulationcoverunified,tidyandbeautiful.Whenfourpartssuchaspipes,boilerinsulation,mustdofirstarticleinspection,proofofdesignandconstructionmethods,technologycanmeetthetechnologicalrequirements,beforeextensiveconstruction.Boilersteelbeams,dooropeningboxesdesignedwithinsulationgaskets,flangecannotbeoblique,evenfastened.Backintotheslopeofthetubingduringinstallationpayattentiontothepiping,oilstationisalowpoint.Refuelingmustbecontrolledwhencastingmaterialparts,selectlowthermalconductivitymaterialsasfaraspossible,ensurethatthesepartsdonotoverheat.6.3qualitydefectsofinsulationtechnologymanagementoptimizationofconstructionprocessanddevelopareasonableduration,regionaltransferofstrictly
C.②③④ D.①④ B.①②③ { Derived obj; obj.funl(); //① obj.fun2(); //② obj.fun3(); //③ obj.fun4(); //④ return 0; } 其中有语法错误的语句是 A.①②③④ (32)有如下程序: #include using namespace std; class Base { public: void funl(){cout<<"Base\n";} virtual void fun2(){cout<<"Base\n";} }; class Derived:public Base { public: void funl(){cout<<"Derived\n";} void fun2(){cout<<"Derived\n";} }; void f(Base& b) { b.fun1(); b.fun2(); } int main() { Derived obj; f(obj); return 0; } 执行这个程序的输出结果是 A. Base Base B.Base Derived C.Derived Base D.Derived Derived (33)有如下程序: #include using namespace std; class Complex { double re, im; public: Complex(double r, double i):re(r), im(i){} double real() const{return re;} double image() const{return im;} 一次,他在核实数据时,认为部分数据需要重新测量,但项目部的车都被派出去了。belimitedtonomorethan2daysofwork,materialdepositedinspecialinsulatedcontainers,materialhandlingtogentlyandmakeuseofthermalinsulationmaterialinwindproof,waterproof,moisture-proofmeasure.6.2thermaldesignoptimizationforhigh-temperaturespecialthermalinsulationforpipingsupportandhangerdesign,reducedheatdissipationofthehangers,ensurethatthewalldoesnotoverheat.Small-diameterpiping,thermalinstrumentlayoutandpositioningofsupportandhangerdesigntakefullyintoaccounttheexpansionspaceandinsulationthickness.Large-diameterpipesafterheatpreservationplasteringconstructionofvalves,turbine,checkingsmoothsurface,hightemperaturepowderpaintfullydryafter.Protectivecoveringsforelectricequipmentinsulationboardsdesignedwithpressureplate,whenorderingaccordingtotheinstallationdiagram,modelspecificationspublishingorder,ensurewheninstallingcornersneat,uniformappearance,reducetheamountofon-sitemachining.Beforevalves,flangeinsulationshellconstruction,besuretomakeaunifiedmodel,allvalves,flanges,insulationcoverunified,tidyandbeautiful.Whenfourpartssuchaspipes,boilerinsulation,mustdofirstarticleinspection,proofofdesignandconstructionmethods,technologycanmeetthetechnologicalrequirements,beforeextensiveconstruction.Boilersteelbeams,dooropeningboxesdesignedwithinsulationgaskets,flangecannotbeoblique,evenfastened.Backintotheslopeofthetubingduringinstallationpayattentiontothepiping,oilstationisalowpoint.Refuelingmustbecontrolledwhencastingmaterialparts,selectlowthermalconductivitymaterialsasfaraspossible,ensurethatthesepartsdonotoverheat.6.3qualitydefectsofinsulationtechnologymanagementoptimizationofconstructionprocessanddevelopareasonableduration,regionaltransferofstrictly7
D.(3, 1) Complex& operator +=(Complex a) { re += a.re; im += a.im; return *this; } }; ostream &operator<<(ostream& s,const Complex& z) { return s<<'('<
分享到:
收藏