| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 619 人关注过本帖
标题:求助???高手帮帮我
只看楼主 加入收藏
libaoan001
Rank: 1
等 级:新手上路
帖 子:13
专家分:6
注 册:2010-4-12
结帖率:100%
收藏
 问题点数:0 回复次数:3 
求助???高手帮帮我
#include<iostream.h>
#include<string.h>
class Student
{
protected:
    int no;
    char name[10];
    float math,cpp;
    static int count;
    static float msum,csum;
    Student*next;
public:
    Student(){}   
    Student(int,char *,float,float,Student*=NULL);
    float sum(){return math+cpp;}
    void show1()
    {
        cout<<no<<'\t'<<name<<'\t'<<math<<'\t'<<cpp<<'\t'<<sum()<<endl;}
    static void show2()
    {
        cout<<(msum/count)<<'\t'<<(csum/count)<<endl;
    }
    friend class stulist;
};
Student::Student(int mo,char*name,float math,float cpp,Student*next)
{
    this->no=no;
    strcpy(this->name,name);
    this->math=math;
    this->cpp=cpp;
    this->next=next;
    count++;msum+=math;;csum+=cpp;
}
class stulist
{
    Student*head;
public:
    stulist(){head=NULL;}
    ~stulist();
    void create();
    void print()const;
};
stulist::~stulist(){
    Student*p;
    while(head){
        p=head;head=head->next;delete p;
    }
}
void stulist::cteate(){
    Student*p1,*p2;
    int no;
    char name[10];
    float math,cpp;
    cout<<"输入学号,-1表示结束";
    cin>>no;
    while(no!=-1){
        cout<<"输入姓名及数学·c++语言成绩";
        cin>>name>>math>>cpp;
        p1=new Student(no,name,math,cpp);
        if(!head){head=p1;p2=p1;}
        else{p2->next=p1;p2=p1;}
        cout<<"输入学号,-1表示结束";
        cin>>no;
    }
}
void stulist::print()const
{
    Student*p=head;
    cout<<"学号\t姓名\t数学\tc++语言\t总分\n";
    while(p){p->show1();p=p->next;}
    cout<<"";
    Student::show2();
}
int Student::count;
float Student::cpunt;
float Student::msum,Student::csum;
void main()
{
    stulist li;
    li.create();
    li.print();
}



哪位高手帮我看看  那里有错误呀
搜索更多相关主题的帖子: static name include public friend 
2010-06-22 16:36
南国利剑
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:29
帖 子:1165
专家分:3536
注 册:2010-4-12
收藏
得分:0 
说说问题出在哪里啊?

南国利剑
2010-06-23 13:14
libaoan001
Rank: 1
等 级:新手上路
帖 子:13
专家分:6
注 册:2010-4-12
收藏
得分:0 
d:\vc\ggg.cpp(14) : error C2629: unexpected 'class Student ('
d:\vc\ggg.cpp(14) : error C2238: unexpected token(s) preceding ';'
d:\vc\ggg.cpp(26) : error C2511: 'Student::Student' : overloaded member function 'void (int,char *,float,float,class Student *)' not found in 'Student'
        d:\vc\ggg.cpp(4) : see declaration of 'Student'
d:\vc\ggg.cpp(49) : error C2039: 'cteate' : is not a member of 'stulist'
        d:\vc\ggg.cpp(35) : see declaration of 'stulist'
d:\vc\ggg.cpp(59) : error C2661: 'Student::Student' : no overloaded function takes 4 parameters
d:\vc\ggg.cpp(60) : error C2065: 'head' : undeclared identifier
d:\vc\ggg.cpp(60) : error C2440: '=' : cannot convert from 'class Student *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\vc\ggg.cpp(61) : error C2248: 'next' : cannot access protected member declared in class 'Student'
        d:\vc\ggg.cpp(11) : see declaration of 'next'
d:\vc\ggg.cpp(75) : error C2039: 'cpunt' : is not a member of 'Student'
        d:\vc\ggg.cpp(4) : see declaration of 'Student'
Error executing cl.exe.

ggg.obj - 9 error(s), 0 warning(s)

2010-06-23 16:22
南国利剑
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:29
帖 子:1165
专家分:3536
注 册:2010-4-12
收藏
得分:0 
回复 3楼 libaoan001

自己写的自己调出来。

南国利剑
2010-06-23 23:09
快速回复:求助???高手帮帮我
数据加载中...
 
   



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

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