![]() |
#2
jcw081201102011-09-24 08:38
晕 在看看 你这个错误还真多!! 不是一个两个 你能把程序全发出来不? 这样可以帮你调试下!
我大概帮你看了下 程序这样 估计可以了 ![]() #include<iostream> #include<string> using namespace std; class Student { public: Student(){}; void InputData(); //ѧéúêy¾Yêäè룻 void LinkData(Student &s); //á′½óѧéúêy¾Y£» void ShowData(); //ÏÔê¾Ñ§éúêy¾Y£» Student *Getnext(); //è¡next; string Getname(); //è¡DÕÃû£» long Getnumber(); //è¡Ñ§oÅ£» float Gerscores(); //è¡3鼨£» Student &AlterName(); //DT¸ÄDÕÃû£» Student &AlterNumber(); //DT¸ÄѧoÅ£» Student &AlterScores(); //DT¸Ä3鼨£» private: string name; long number; float scores; Student *next; }; void Student::ShowData(void) { cout<<"DÕÃû\tѧoÅ\t3鼨:"<<endl; cout<<name<<"\t"<<number<<"\t"<<scores<<endl; } void Student::InputData() { cout<<"Çëêäèëѧéúêy¾Y:"<<endl; cout<<"DÕÃû\tѧoÅ\t3鼨"<<endl; cin>>name>>number>>scores; } void Student::LinkData(Student &s) { next = s.next; } Student* Student::Getnext() { return next; } string Student::Getname() { return name; } long Student::Getnumber() { return number; } float Student::Gerscores() { return scores; } Student& Student::AlterName() { string new_name; cout<<"ÇëêäèëDÂÃû×Ö:"<<endl; cin>>new_name; name = new_name; return *this; } Student& Student::AlterNumber() { long new_number; cout<<"ÇëêäèëDÂѧoÅ:"<<endl; cin>>new_number; number = new_number; return *this; } Student& Student::AlterScores() { float new_scores; cout<<"ÇëêäèëDÂ3鼨:"<<endl; scores = new_scores; return *this; } [ 本帖最后由 jcw08120110 于 2011-9-24 08:49 编辑 ] |
运行起来,怎么莫名的错误呢?
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