首页 > 全部 > 二级C++ > 国家二级C++机试(操作题)模拟试卷290

国家二级C++机试(操作题)模拟试卷290

本单篇文档共4285字,内容预览3600字,预览为有答案版,源文件无水印,下载后包含无答案空白卷版和有答案版,同时也有计算机类NCRE全国计算机二级整科真题模拟题,讲义课件,思维导图,易错高频题等下载。
二级C++ 章节练习 6109人下载
价格: 1.00 原价:¥8.80
收藏

国家二级C++机试(操作题)模拟试卷290

基本操作题

1.请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:

Name:Smith Age:21 ID:99999 Course-

Num:12 Record:970

注意:只修改每个“//ERROR ****found****”下的那一行,不要改动程序中的其他内容。

#include<iostream>

using namespace std;

class StudentInfo

{

protected:

//ERROR*******found*******

char Name;

int Age;

int ID;

int CourseNum;

float Record,

public:

StudentInfo(char * name,int

Age f int ID, int courseNum,

float record);

//ERROR*******found*******

void~StudentInfo(){}

float AverageRecord(){

return Record/CourseNum;

}

void show()const{

cout<<\\

(1)char * Name;

(2)~Studentlnfo(){}

(3)StudentInfo∷Studentlnfo(char * name,int age,int ID,int coumeNum,float record)

解析:

简单应用题

2.请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,其中定义了vehicle类,并派生出motorcar类和bicycle类。然后以motorcar和bicycle作为基类,再派生出motorcycle类。要求将vehicle作为虚基类,避免二义性问题。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:

80

150

100

1

注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。

#include<iostream.h>

class vehicle

{

private:

int MaxSpeed;

int Weight;

public:

//**********found**********

vehicle(int maxspeed,int

weight):_______

~vehicle(){};

int getMaxSpeed() { return MaxSpeed;}

int getWeight() {return

Weight;}

};

//**********found**********

class bicycle:_______public

vehicle

{

private:

int Height;

public:

bicycle(int maxspeed,int

weight,int height):vehicle

(maxspeed, weight),Height

(height){)

int getHeight(){ return

Height;};

};

//**********found**********

class motorcar:_______public vehicle

{

private:

int SeatNum;

public:

motorcar(int maxspeed,int weight,int seatnum):vehicle

(maxspeed, weight),SeatNum

(seatnum){}

int getSeatNum(){return SeatNum;};

};

//**********found**********

class motorcycle:_______

{

public:

motorcycle(int maxspeed,int weight,int height):vehicle

(maxspeed, weight),bicycle(maxspeed,weight,height),motorcar(maxspeed,weight,1){}

};

VOid main()

{

motorcycle a(8 0,150,100);

cout<<a.getMaxSpeed() <<end1;

cout<<a.getWeight()<<end1;

cout<<a.getHeight()<<end1;

cout<<a.getSeatNum()<<end1;

}

(1)MaxSpeed(maxspeed),Weight(weight){};

(2)virtual

(3)virtual

(4)public bicycle,public motorcar

解析:(1)主要考查考生对构造函数的掌握,构造函数使用初始化列表来对私有成员MaxSpeed和Weight初始化。

(2)主要考查考生对派生类的掌握,题目要求将vehicle作为虚基类,避免二义性问题。因此在这里添加virtual使vehicle成为虚基类。

(3)主要考查考生对派生类的掌握,题目要求以motorcar和bicycle作为基类,再派生出motorcycle类。在主函数中可以看到motorcycle类的实例a调用getHeight函数和getSeatNum函数,由此可知这两个基类都是公有继承,因此得出语句:public bicycle,public motorcar。

综合应用题

3.请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中声明的CDeepCopy是一个用于表示矩阵的类。请编写这个类的赋值运算符成员函数operator=,以实现深层复制。

要求:

补充编制的内容写在“//**********333**********”与“**********666**********”之间。不得修改程序的其他部分。

注意:程序最后将结果输出到文件out.dat中。输出函数writeT

本文档预览:3600字符,共4285字符,源文件无水印,下载后包含无答案版和有答案版,查看完整word版点下载

剩余未完,查看全文
收藏
国家二级C++机试(操作题)模拟试卷290

推荐资源

客服

扫码添加客服微信

热线

官方客服

如遇问题,请联系客服为您解决

电话客服:

客服微信:pujinet

工作时间:9:00-18:00,节假日休息

公众号

扫码关注微信公众号