编译没问题。一运行就出错,不知道哪里错了。
#include<iostream>#include<string>
using namespace std;
class student
{
private:
int no;
string name;
double deg1,deg2,deg3;
static double sum1;
static double sum2;
static double sum3;
static int count;
public:
double av1,av2,av3;
void student1()
{ cin>>no>>name>>deg1>>deg2>>deg3;
sum1=sum1+deg1;
sum2=sum2+deg2;
sum3=sum3+deg3;}
void ave1()
{ av1=sum1/count;}
void ave2()
{ av2=sum2/count;}
void ave3()
{av3=sum2/count;}
static void disp()
{ cout<<"语文成绩的平均分为:"<<sum1<<endl;
cout<<"数学成绩的平均分为:"<<sum2<<endl;
cout<<"英语成绩的平均分为:"<<sum3<<endl;}
};
double student::sum1=0;
double student::sum2=0;
double student::sum3=0;
int main()
{ int count,a;
student A[100];
cout<<"请输入学生数据的个数:"<<endl;
cin>>count;
cout<<"请输入学生信息"<<endl;
for(a=0;a<count;a++)
{ A[a].student1();}
A[a].ave1();
A[a].ave2();
A[a].ave3();
student::disp();
return 0;}
错误提示:Debug/学生成绩.exe : fatal error LNK1120: 1 unresolved externals