主题:这个student类怎么了?????
运行起来,怎么莫名的错误呢?
class Student
{
public:
Student(){}
void InputData(); //学生数据输入;
void LinkData(Student &s); //链接学生数据;
void ShowData(); //显示学生数据;
Student *Getnext(); //取next;
string Getname(); //取姓名;
long Getnumber(); //取学号;
float Gerscores(); //取成绩;
Student &AlterName(); //修改姓名;
Student &AlterNumber(); //修改学号;
Student &AlterScores(); //修改成绩;
private:
string name;
long number;
float scores;
Student *next;
};
void Student::ShowData(void)
{
cout<<"姓名\t学号\t成绩:"<<endl;
cout<<name<<"\t"<<number<<"\t"<<scores<<endl;
}
void Student::InputData()
{
cout<<"请输入学生数据:"<<endl;
cout<<"姓名\t学号\t成绩"<<endl;
cin>>name>>number>>scores;
}
void Student::LinkData(Student &s)
{
next = s;
}
Student Student::*Getnext()
{
return next;
}
string Student::Getname()
{
return name;
}
long Student::Getnumber()
{
return nunber;
}
float Student::Gerscores()
{
return scores;
}
Student Student::&AlterName()
{
string new_name;
cout<<"请输入新名字:"<<endl;
cin>>new_name;
name = new_name;
return *this;
}
Student Student::&AlterNumber()
{
long new_number;
cout<<"请输入新学号:"<<endl;
cin>>new_number;
number = new_number;
return *this;
}
Student Student::&AlterScores()
{
float new_scores;
cout<<"请输入新成绩:"<<endl;
scores = new_scores;
return *this;
}
错误提示:
e:\c++\c++program\学生成绩管理系统\class.h(9) : error C2146: syntax error : missing ';' before identifier 'Getname'
e:\c++\c++program\学生成绩管理系统\class.h(9) : error C2501: 'string' : missing storage-class or type specifiers
e:\c++\c++program\学生成绩管理系统\class.h(17) : error C2146: syntax error : missing ';' before identifier 'name'
e:\c++\c++program\学生成绩管理系统\class.h(17) : error C2501: 'string' : missing storage-class or type specifiers
e:\c++\c++program\学生成绩管理系统\class.h(17) : error C2501: 'name' : missing storage-class or type specifiers
e:\c++\c++program\学生成绩管理系统\class.h(26) : error C2065: 'cout' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(26) : error C2297: '<<' : illegal, right operand has type 'char [16]'
e:\c++\c++program\学生成绩管理系统\class.h(26) : error C2065: 'endl' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(27) : error C2065: 'name' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(27) : error C2297: '<<' : illegal, right operand has type 'char [2]'
e:\c++\c++program\学生成绩管理系统\class.h(32) : error C2297: '<<' : illegal, right operand has type 'char [16]'
e:\c++\c++program\学生成绩管理系统\class.h(33) : error C2297: '<<' : illegal, right operand has type 'char [15]'
e:\c++\c++program\学生成绩管理系统\class.h(35) : error C2065: 'cin' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(35) : error C2296: '>>' : illegal, left operand has type 'float'
e:\c++\c++program\学生成绩管理系统\class.h(35) : error C2297: '>>' : illegal, right operand has type 'float'
e:\c++\c++program\学生成绩管理系统\class.h(40) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class Student' (or there is no acceptable conversion)
e:\c++\c++program\学生成绩管理系统\class.h(45) : error C2065: 'next' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(47) : error C2143: syntax error : missing ';' before 'tag::id'
e:\c++\c++program\学生成绩管理系统\class.h(47) : error C2501: 'string' : missing storage-class or type specifiers
e:\c++\c++program\学生成绩管理系统\class.h(47) : fatal error C1004: unexpected end of file found
class Student
{
public:
Student(){}
void InputData(); //学生数据输入;
void LinkData(Student &s); //链接学生数据;
void ShowData(); //显示学生数据;
Student *Getnext(); //取next;
string Getname(); //取姓名;
long Getnumber(); //取学号;
float Gerscores(); //取成绩;
Student &AlterName(); //修改姓名;
Student &AlterNumber(); //修改学号;
Student &AlterScores(); //修改成绩;
private:
string name;
long number;
float scores;
Student *next;
};
void Student::ShowData(void)
{
cout<<"姓名\t学号\t成绩:"<<endl;
cout<<name<<"\t"<<number<<"\t"<<scores<<endl;
}
void Student::InputData()
{
cout<<"请输入学生数据:"<<endl;
cout<<"姓名\t学号\t成绩"<<endl;
cin>>name>>number>>scores;
}
void Student::LinkData(Student &s)
{
next = s;
}
Student Student::*Getnext()
{
return next;
}
string Student::Getname()
{
return name;
}
long Student::Getnumber()
{
return nunber;
}
float Student::Gerscores()
{
return scores;
}
Student Student::&AlterName()
{
string new_name;
cout<<"请输入新名字:"<<endl;
cin>>new_name;
name = new_name;
return *this;
}
Student Student::&AlterNumber()
{
long new_number;
cout<<"请输入新学号:"<<endl;
cin>>new_number;
number = new_number;
return *this;
}
Student Student::&AlterScores()
{
float new_scores;
cout<<"请输入新成绩:"<<endl;
scores = new_scores;
return *this;
}
错误提示:
e:\c++\c++program\学生成绩管理系统\class.h(9) : error C2146: syntax error : missing ';' before identifier 'Getname'
e:\c++\c++program\学生成绩管理系统\class.h(9) : error C2501: 'string' : missing storage-class or type specifiers
e:\c++\c++program\学生成绩管理系统\class.h(17) : error C2146: syntax error : missing ';' before identifier 'name'
e:\c++\c++program\学生成绩管理系统\class.h(17) : error C2501: 'string' : missing storage-class or type specifiers
e:\c++\c++program\学生成绩管理系统\class.h(17) : error C2501: 'name' : missing storage-class or type specifiers
e:\c++\c++program\学生成绩管理系统\class.h(26) : error C2065: 'cout' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(26) : error C2297: '<<' : illegal, right operand has type 'char [16]'
e:\c++\c++program\学生成绩管理系统\class.h(26) : error C2065: 'endl' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(27) : error C2065: 'name' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(27) : error C2297: '<<' : illegal, right operand has type 'char [2]'
e:\c++\c++program\学生成绩管理系统\class.h(32) : error C2297: '<<' : illegal, right operand has type 'char [16]'
e:\c++\c++program\学生成绩管理系统\class.h(33) : error C2297: '<<' : illegal, right operand has type 'char [15]'
e:\c++\c++program\学生成绩管理系统\class.h(35) : error C2065: 'cin' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(35) : error C2296: '>>' : illegal, left operand has type 'float'
e:\c++\c++program\学生成绩管理系统\class.h(35) : error C2297: '>>' : illegal, right operand has type 'float'
e:\c++\c++program\学生成绩管理系统\class.h(40) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class Student' (or there is no acceptable conversion)
e:\c++\c++program\学生成绩管理系统\class.h(45) : error C2065: 'next' : undeclared identifier
e:\c++\c++program\学生成绩管理系统\class.h(47) : error C2143: syntax error : missing ';' before 'tag::id'
e:\c++\c++program\学生成绩管理系统\class.h(47) : error C2501: 'string' : missing storage-class or type specifiers
e:\c++\c++program\学生成绩管理系统\class.h(47) : fatal error C1004: unexpected end of file found