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

admin2020-06-29  25

问题 请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Name:Smith    Age:21    ID:99999    Coure-Num:12    Record:970
    注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。
#include
using namespace std;
class StudentInfo
{
protected:
//ERROR  ********found********
  char Name;
  int Age;
  int ID;
  int CourseNum;
  float Record;
public:
  StudentInfo(char*name,intAge , int IDf int courseNum ,float record);
//ERROR********found********
  void~StudentInfo(){)
  float AVerageRecord(){
    return Record/CourseNum;
    }
    void show()const{
    cout<<"Name:"<    <<"CourseNum:"<    }
};
//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)StudentInfo::StudentInfo(char*name,int age,int ID,int courseNum,float record)

解析 (1)主要考查考生对动态数组的掌握,由题目可知Name应该指向一个动态数组,而不是一个有效char型字符,因此要定义成char型指针。
    (2)主要考查考生对析构函数的掌握,析构函数不需要函数返回类型,应把void去掉。
    (3)主要考查考生对构造函数定义的掌握,构造函数也要使用作用域符号“::”。
转载请注明原文地址:https://kaotiyun.com/show/Pzyp777K
0

相关试题推荐
最新回复(0)