看看这个程序错哪了,谢谢!
#include<iostream.h>
class student
{public:
void scoretotalcount(float s);
static float sum();
static float average();
student*next;
private:
float score;
static float total;
static int count;
};
void student::scoretotalcount(float s)
{score=s;total+=score;count++;}
float student::sum()
{return total;}
float student::average()
{float average=total/count;return average;}
void add(student*&f,student*&r,float s)
{student *p=new student;
p->scoretotalcount(s);
p->next=NULL;
if(f==NULL)
{f=r=p;}
else
{r->next=p;r=r->next;}
void main()
{student * front=NULL;student * rear=NULL;
float s;
int choice;
do
{cout<<"请选择是否继续输入"<<endl;
cout<<"输入1继续,\n输入0结束\n";
cin>>choice;
switch(choice)
{case 1:
{ cout<<"输入成绩:";
cin>>s;
add(front,rear,s);
break;
}
case 0:
{break;}
}
cout<<"总分数是:"<<student::sum()<<endl;
cout<<"平均分是:"<<student::average()<<endl;
}while(choice);
}