首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请打开考生文件夹下的解决方案文件proj1,程序中位于每个“//ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 注意:只修改每个“//ERROR ****found****”下的那一行,不要改动
请打开考生文件夹下的解决方案文件proj1,程序中位于每个“//ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 注意:只修改每个“//ERROR ****found****”下的那一行,不要改动
admin
2019-04-24
39
问题
请打开考生文件夹下的解决方案文件proj1,程序中位于每个“//ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:
注意:只修改每个“//ERROR ****found****”下的那一行,不要改动程序中的其他内容。
#include
using namespace std;
class StudentInfo
{
protected:
//ERROR ****found****
cham Name;
int Age;
int ID;
int CourseNum;
float Record;
public:
Student Info(char*name,int
Age,int ID,int courseNum,
float record);
//ERROR ********found********
void ~StudentInfo(){}
float AVerageRecord(){
return Record/CourseNum;
}
void show()const{
cout<<”Name:"<
Age:"<
<<"CourseNum:"<<
CourseNum<<"Record:"<
cord<
}
};
//ERROR ********found********
StudentInfo StudentInfo(char
*Name,int Age,int ID,int
CourseNum,float Record)
{
Name=name ;
Age=age;
this->ID=ID;
CourseNum=courseNum;
Record=record;
}
int main()
{
StudentInfo st("Smith",21,99999,12,970);
st.show();
return 0;
}
选项
答案
(1)char*Name; (2)~StudentInfo(){} (3)Studentlnfo::Studentlnfi*(char*name,intage,int ID.int courseNum,float record)
解析
(1)主要考查考生对动态数组的掌握,由题目可知Name应该指向一个动态数组,而不是一个有效char型字符,因此要定义成char型指针。
(2)主要考查考生对析构函数的掌握,析构函数不需要函数返回类型,应把void去掉。
(3)主要考查考生对构造函数定义的掌握,构造函数也要使用作用域符号“::”。
转载请注明原文地址:https://kaotiyun.com/show/TOAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
如下程序的输出结果是______。#include<iostream>usingnamespacestd;intfunl(intx){return++x;}intfun2(int&x){return++x;
下列程序的输出结果是()。#include<iostream>usingnamespacestd;template<typenameT>Tfun(Ta,Tb){return(a<=b)?a:b;)
下面程序的输出结果是()。#include<iostream>#include<math.h>usingnamespacestd;classpoint{private:doubl
下列程序的输出结果是()。#include<iostream>usingnamespacestd;voidfun(int&r){r*=2;}intmain(){int
有以下程序段:#include<iostream.h>#defineMAX(x,y)(x)>(y)?(x):(y)voidmain(){inti,j,k;i=10;j=15;k=MAX(i
有以下程序,输出结果()。#include<iostream>usingnamespacestd;classComplex{public:Complex(doubler=0,doublei=
表达式x.operator+(y.operator++(0))还可以写成______。
按照标识符的要求,下列选项中,()符号不能组成标识符。
下面的符号中不属于C++关键字的是()。
随机试题
“运用描绘、雕塑、拓印、拼贴等手段和方法制作视觉形象的美术创作活动”是“()”学习领域内容。[江西2020]
资产评估中的投资价值是指资产()
下列选项中不影响管理道德的因素是()
Thedoghasalwaysbeenconsideredman’sbestfriend.Alwaysnotedforbeingparticularlyfaithfulinwatchingoverchildren,he
前列腺增生症早期最常见的症状是
汉译英:“船舶;车辆”,正确的翻译为()。
下面不属于市场营销活动功能的是()。
下面各句中加横线的词语如果用括号里的词来替换,有什么好处,选出说明有错的一项______。
设f(x)在[a,b]上连续可导,且f(a)=f(b)=0.证明:|f(x)|≤1/2∫ab|f′(x)|dx(a<x<b).
WhichofthefollowinghasnothingtodowithScreenblast?
最新回复
(
0
)