| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 495 人关注过本帖
标题:这个student类怎么了???????
只看楼主 加入收藏
林浩
Rank: 2
等 级:论坛游民
帖 子:47
专家分:23
注 册:2011-1-12
结帖率:90.91%
收藏
已结贴  问题点数:10 回复次数:1 
这个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
2011-09-24 08:19
jcw08120110
Rank: 8Rank: 8
来 自:南京
等 级:蝙蝠侠
帖 子:272
专家分:742
注 册:2009-6-8
收藏
得分:10 
晕 在看看 你这个错误还真多!! 不是一个两个 你能把程序全发出来不? 这样可以帮你调试下!
我大概帮你看了下   程序这样 估计可以了   


程序代码:
#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 编辑 ]

君生我未生 我生君以老
2011-09-24 08:38
快速回复:这个student类怎么了???????
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015584 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved