.,float sco ):Person(nam,s,a),score(s){};后面为什么只有score(s)就行了?score也不是类型啊class Student:public Person{public:\x09Student(string,char,int,float);\x09void display();private:float score;};Student::Student(string nam,char s

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/18 02:32:42

.,float sco ):Person(nam,s,a),score(s){};后面为什么只有score(s)就行了?score也不是类型啊class Student:public Person{public:\x09Student(string,char,int,float);\x09void display();private:float score;};Student::Student(string nam,char s
.,float sco ):Person(nam,s,a),score(s){};后面为什么只有score(s)就行了?score也不是类型啊
class Student:public Person
{
public:
\x09Student(string,char,int,float);
\x09void display();
private:
float score;
};
Student::Student(string nam,char s,int a,float sco ):Person(nam,s,a),score(s){} //////为什么只有、/////score(s)就行了啊?score不是类名啊!
void Student::display()
{
\x09Person::display();
\x09cout

.,float sco ):Person(nam,s,a),score(s){};后面为什么只有score(s)就行了?score也不是类型啊class Student:public Person{public:\x09Student(string,char,int,float);\x09void display();private:float score;};Student::Student(string nam,char s
这是构造函数初始化参数的一种形式,比在构造函数体内部赋值要好.