首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请打开考生文件夹下的解决方案文件proj1,程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Name:Smith Age:21 ID:99999 CourseNum:12 Rec
请打开考生文件夹下的解决方案文件proj1,程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Name:Smith Age:21 ID:99999 CourseNum:12 Rec
admin
2018-07-06
13
问题
请打开考生文件夹下的解决方案文件proj1,程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Name:Smith Age:21 ID:99999 CourseNum: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,intAge,int ID,int courseNum,float record);
//ERROR*******found*******
VOid~StudentInfo( ){}
float AVerageRecord( ){
return Record/CourseNum;
}
void show( )const{
cout<<"Name:"<<Name<<"Age:"<<Age<<"ID:"<<ID
<<"CourSeNum:"<<
CourSeNum<<"ReCOrd:"<<Re-cord<<endl;
}
};
//ERROR*******found*******
StudentInfo StudentInfo(char*Name,int Age,int ID,intCourseNum,float Record)
{
Name=name;
Age=age;
this->ID=ID;
CourSeNum=courSeNum;
Record=record;
}
int main( )
{
StudentInfo st("Smith",21,99999,12,970);
st.show( );
return0;
}
选项
答案
(1)char*Name; (2)~StudentInfo( ){} (3)Studentlnfo::Studentlnfo(char*name,int age,int ID,int courseNum,float record)
解析
(1)主要考查考生对动态数组的掌握,由题目可知Name应该指向一个动态数组,而不是一个有效char型字符,因此要定义成char型指针。
(2)主要考查考生对析构函数的掌握,析构函数不需要函数返回类型,应把void去掉。
(3)主要考查考生对构造函数定义的掌握,构造函数也要使用作用域符号“::”。
转载请注明原文地址:https://kaotiyun.com/show/RAAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列程序运行后的输出结果是()。#include<iostream.h>voidfun(int,int,int*);voidmain(){intx,y,z;fun(5,6,&x);
有如下程序:#include<iostream>usingnamespacestd;classBase{public:voidfun(){cout<<"Base::fun"<<e
有如下程序:#include<iostream>usingnamespacestd;intmain(){int*p;*p=9;cout<<"Thev
对建立良好的程序设计风格,下列描述中正确的是()。
在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。#include<iostream.h>usingnamespacestd;classA{public:A(){cout<<‘A’;}};
如果要把返回值为void的函数A声明为类B的友元函数,则应在类B的定义中加入的语句是______。
一个函数为voidf(int,charch=’a’),另一个函数为voidf(iht),则它们()。
下列程序的输出结果是()。#include<iostream>usingnamespacestd;classTestClass{staticinti;public:
随机试题
抢救休克型中毒性痢疾,哪项措施不得当
影响Χ线强度的因素中,不包括
某实验室用同一检验方法测定食品中的铅。小李的测定误差为2%,小王的测定误差为10%,经统计检验,检测结果不存在离群值。两人检测的误差相差那么大,是因为存在
对于不同的生态功能区实行分类管理政策,产业政策要引导优化开发区域转移(),提升产业结构层次。
甲公司为增值税一般纳税人,适用的增值税税率为17%,每月月初发放上月工资,2016年12月1日,“应付职工薪酬”科目贷方余额为33万元。该企业2016年12月发生职工薪酬业务如下:(1)5日,结算上月应付职工薪酬33万元。其中代扣代缴的职工个人所得税1.
关于中期财务报告的确认与计量,下列说法中正确的有()。
2016年8月28日,中国航空发动机集团公司成立大会在北京举行。下列关于航空发动机的说法错误的是()。
新民主主义理论的基本点有
如果一个过程不包含RETURN语句,或者RETURN语句中没有指定表达式,那么该过程:
Thiswillmakeschoolsmoredirectlyandeffectively______toparents,andmoreresponsivetotheircriticismsandwishes.
最新回复
(
0
)