[计算机类试卷]国家二级(C++)机试模拟试卷92及答案与解析.doc
《[计算机类试卷]国家二级(C++)机试模拟试卷92及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级(C++)机试模拟试卷92及答案与解析.doc(30页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级( C+)机试模拟试卷 92及答案与解析 一、选择题 1 数据流图中带有箭头的线段表示的是 ( )。 ( A)控制流 ( B)事件驱动 ( C)模块调用 ( D)数据流 2 在下列原型所示的 C+函数中,按 “传值 “方式传递参数的是 ( )。 ( A) voidf1(intx); ( B) voidf2(int*x); ( C) voidf3(constint*x); ( D) voidf4(int 3 有如下程序: #include using namespace std; class Part public: Part(int x=0):val(x) cout using nam
2、espace std; class Point public: Point(int xx=0,int yy=0):x(xx),y(yy) protected: void SetXY(int xx,int yy) x=xx; y=yy; private: int x,y; ; class Circle:public Point public: Circle(int r):radius(r) void Set(int r,int x,int y) radius=r; SetXY(x,y); / void Print() const cout #include using namespace std
3、; class Animal public: virtual string GetType() const return “Animal“; virtual string GetVoice() const return “Voice“; ; class Dog:public Animal public: string GetType() const return “Dog“; string GetVoice() const return “Woof“; ; class Cat:public Animal public: string GetType() const return “Cat“;
4、string GetVoice() const return “Miaow“; ; void Type(Animal a) cout using namespace std; class GA public: virtual int f() return 1; ; class GB: public GA public: virtual int f() return 2; ; void show(GA g) cout #include using namespace std; class Animal public: virtual string GetType() const return “
5、Animal“; virtual string GetVoice() const return “Voice“; ; class Dog:public Animal public: string GetType() const return “Dog“; string GetVoice() const return “Woof“; ; class Cat:public Animal public: string GetType() const return “Cat“; string GetVoice() const return “Miaow“; ; void Type(Animal a)
6、coutTabs(Tx)returnxTabs(Tx)returnxabs(Tx)returnx using namespace std; class TV public: TV(int s=41):size(s) void Print() coutTfun(Tx)returnx*x; ( B) templateTfun(Tx,intn)returnx+n; ( C) templateTfun(T*p)return*p; ( D) templateTfun()returnT; 二、基本操作题 41 请使用 VC6或使用【 答题】菜单打开考生文件夹 pmjl下的工程 proj1,此工程中含有一个
7、源程序文件 proj1 cpp。 其中位于每个注释 “ ERROR*found*”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: Constructorcalled Thevalueis10 Maxnumberis20 Destructorcalled 注意:只能修改注释 “ ERROR*found*”的下一行语句,不要改动程序中的其他内容。 proj1 cpp #include usingnamespacestd; classMyClass public: ERROR*found* voidMyClass(inti) value=i; couty? X: y; )求两个整数的最
8、大值 ERROR*found* intMax(intx, inty, intz=0) 求三个整数的最大值 if(xy) returnxz?x: z; else returnyz?y: z; intGetValue()constreturnvalue; MyClass()cout usingnamespacestd; classShape public: Shape() Shape() *found* _floatGetArea()=0; *found* _floatGetPerim()=0; ; classCircle: publicShape public: Circle(floatradi
9、us): itsRadius (radius) Circle() floatGetArea()return3 14*itsRadius*itsRadius; floatGetPerim() return6 28*itsRadius, private: floatitsRadius; ; classRectangle: publicShape public: *found* Rectangle(floatlen, floatwidth): _; Rectangle(); virtualfloatGetArea() returnitsLength*itsWidth; floatGetPerim()
10、 return2*itsLength+2*itsWidth; virtualfloatGetLength()return itsLength; virtualfloatGetWidth()returnitsWidth; private: floatitsWidth; floatitsLength; ; intmain() *k*found* sp=newCircle(5); coutGetArea()GetPerim()GetArea()GetPerim()data=newchar100; this-createSeptinary(num); Septinary: Septinary() if
11、(data!=NULL) deletedata; voidSeptinary: createSeptinary(int num) *333* *666* charSeptinary: numberToChar(int num) if(num7) cout #include usingnamespacestd; classSeptinary七进制类 private: char*data; public: Septinary(intnum); Septinary(); voidcreateSeptinary(intnum); charnumberToChar(intnum); voidshow()
12、; ; voidwriteToFile(constchar*path); 国家二级( C+)机试模拟试卷 92答案与解析 一、选择题 1 【正确答案】 D 【试题解析】 数据流图中带箭头的线段表示的是数据 流,即沿箭头方向传送数据的通道,一般在旁边标注数据流名。 2 【正确答案】 A 【试题解析】 函数参数的 3种传递方式: 将变量名作为形参和实参,即传值方式; 传递变量指针; 引用形参。其中 B、 C选项都是传递变量指针, D选项为引用形参,所以本题答案为 A。 3 【正确答案】 B 【试题解析】 本题考查带参数的构造函数。本题中定义了一个对象 obj,那么执行其构造函数,初始化 p1,p2
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 模拟 92 答案 解析 DOC
