首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Name:Smith Age:21 ID:99999
请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Name:Smith Age:21 ID:99999
admin
2021-06-10
52
问题
请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Name:Smith Age:21 ID:99999 CourseNum:12Record:970
注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。
1 #include<20StEeam>
2 using namespace stct;
3 Class StudentIinfo
4 {
5 protected:
6 //ERROR ********found********
7 char Name;
8 int Age;
9 int ID;
10 int CourseNum;
11 f20aL Record;
12 public:
13 StudentInfo(char*name,int Age,int ID,int courseNum,float:record);
14
15 //ERROR ********found********
16 void~StudentInfo(){)
17 float AverageRecord(){
18 return Record/CourseNum;
19 }
20 VOid show()corlst{
21 cout<<"Name:"<
<
22 <<"CourseNum:"<
23 }
24 };
25 //ERROR ********found********
26 Student;Tnfo StudentInfo (char *Name,int Age,inL ID,int CourseNum, float Record)
27 {
28 Name=name;
29 Age=age;
30 this->ID=ID;
3l CourseNum=courseNum;
32 Record=Eecord;
33 }
34 int main()
35 {
36 StudentInfo st("Smith",21,99999,12,970);
37 st.show();
38 return 0;
39 }
选项
答案
(1)char* Name; (2)~Studentlnfo(){} (3)Studentlnfo::Studentlnfo(char*name,int age,intID.int courseNum,float record)
解析
(1)主要考查考生对动态数组的掌握,由题目可知Name应该指向一个动态数组,而不是一个有效char型字符,因此要定义成char型指针。
(2)主要考查考生对析构函数的掌握,析构函数不需要函数返回类型,应把void去掉。
(3)主要考查考生对构造函数定义的掌握,构造函数也要使用作用域符号“::”。
转载请注明原文地址:https://kaotiyun.com/show/Y0fp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序;#inc1ude<iostream>usingnamespacestd;voidfl(int&x,int&y){intx;x=y;y=z;}voidfZ(:intx,inty){intx;x
有如下程序:#include<iostream>usingnamespacestd;classA{public:A(){cout<<="A";}};classB{public:B(){cout<<"B";}}classC:public
下列选项中不属于面向对象程序设计特征的是()。
有如下程序:#includeusingnamespacestd;classPair{intm;intn;public:Pair(inti,intj):m(i),n
派生类的对象对它的基类成员中()是可以访问的。
有如下程序:#includeusingnamespacestd;intmain(){cout.fill(‘*’);cout.width(6);cout.fill(‘#’);
下列叙述中正确的是
下列选项中,正确的C++标识符是
对长度为n的线性表进行顺序查找,在最坏情况下所需要的比较次数为()。
已知类MyClock中未显式定义构造函数,并重载了加法运算符,使得下面的语句序列能够正确执行:MyClockc1,c2;//……c2=c1+10;由此可知:为类MyClock重载的“+”运算符函数的声明是(
随机试题
看到这种手势信号时怎样行驶?
Myfather’sreactiontothebankbuildingat43rdStreetandFifthAvenueinNewYorkcitywasimmediateanddefinite:"Youwon’
室外消火栓按其进水口的公称通径可分为()。
下列不属于教学设计环节的是()。
宋元是山水画的鼎盛时期,其中以画“寒林平远”著称的画家是()。
A、 B、 C、 D、 A
CTN/CTNS
compositematerials
WillthereeverbeanotherEinstein?ThisistheundercurrentofconversationatEinsteinmemorialmeetingsthroughouttheyear.
以下是一个竞赛评分程序。其功能是去掉8位评委中的一个最高分和一个最低分,计算平均分。DimmaxAsInteger,minAsIntegerDimiAsInteger,xAsInteger,sAsIntegermax=
最新回复
(
0
)