[Error] C:\Users\liweida\Documents\C-Free\未命名3.cpp:34: undefined reference to `student1::c'
#include<iostream>usingnamespacestd;classstudent1{public:intn;charna[20];chars;static...
#include<iostream>
using namespace std;
class student1
{ public:
int n;char na[20];char s;static float cpp;static float shu;static float wu;
student1(){num=n;strcpy(name,na);sex=s;c=cpp;gaoshu=shu;dawu=wu;}
static void total();
static float average11();
static float average12();
static float average13();
static float max11();
static float max12();
static float max13();
static float min11();
static float min12();
static float min13();
student1 *next;
private:
int num;
char name[20];
char sex;
static float c;
static float gaoshu;
static float dawu;
static int count1;
static float sum11;
static float sum12;
static float sum13;
static float max1,max2,max3;
static float min1,min2,min3;
};
void student1::total()
{
sum11+=c;
sum12+=gaoshu;
sum13+=dawu;
count1++;
}
float student1::average11()
{
return(sum11/count1);
}
float student1::average12()
{
return(sum12/count1);
}
float student1::average13()
{
return(sum13/count1);
}
float student1::max11()
{
if(max1<c)
max1=c;
return max1;
}
float student1:: max12()
{
if(max2<gaoshu)
max2=gaoshu;
return max2;
}
float student1:: max13()
{
if(max3<dawu)
max3=dawu;
return max3;
}
float student1:: min11()
{
if(min1<c)
min1=c;
return min1;
}
float student1:: min12()
{
if(min2<gaoshu)
min2=gaoshu;
return min2;
}
float student1:: min13()
{
if(min3<dawu)
min3=dawu;
return min3;
}
float student1::sum11=0;
float student1::sum12=0;
float student1::sum13=0;
int student1::count1=0;
float max1=0,max2=0,max3=0;
float min1=0,min2=0,min3=0;
float cpp=0,shu=0,wu=0;
int main()
{
void change(student1 *p1);
int n,i=1;char mark='Y',r;
student1 *p,*k1;
p=new student1;
for(n=1;mark=='Y';n++)
{
p->next=new student1;
change(p);
cout<<"共输入了"<<n<<"个学生,继续输入请按Y,停止输入请按N :";
cin>>r;
mark=r;
k1=p;
}k1=NULL;
cout<<"**********共计"<<n-1<<"个学生************"<<endl;
return 0;
}
void change(student1 *p1)
{
int a;
cout<<"请选择输入:理科按1"<<endl;
cin>>a;
if(a==1)
{
cout<<"***********请修改该理工科学生信息************"<<endl;
cout<<"请输入学号:";
cin>>p1->n;
cout<<"请输入姓名:";
cin>>p1->na;
cout<<"请输入性别:";
cin>>p1->s;
cout<<"请输入该理工科学生成绩:";
cout<<"请输入c++成绩:";
cin>>p1->cpp;
cout<<"请输入高数成绩:";
cin>>p1->shu;
cout<<"请输入大物成绩:";
cin>>p1->wu;
cout<<"**************恭喜该生信息修改完成*****************"<<endl;
p1=p1->next;
}
}
这是为什么啊? 展开
using namespace std;
class student1
{ public:
int n;char na[20];char s;static float cpp;static float shu;static float wu;
student1(){num=n;strcpy(name,na);sex=s;c=cpp;gaoshu=shu;dawu=wu;}
static void total();
static float average11();
static float average12();
static float average13();
static float max11();
static float max12();
static float max13();
static float min11();
static float min12();
static float min13();
student1 *next;
private:
int num;
char name[20];
char sex;
static float c;
static float gaoshu;
static float dawu;
static int count1;
static float sum11;
static float sum12;
static float sum13;
static float max1,max2,max3;
static float min1,min2,min3;
};
void student1::total()
{
sum11+=c;
sum12+=gaoshu;
sum13+=dawu;
count1++;
}
float student1::average11()
{
return(sum11/count1);
}
float student1::average12()
{
return(sum12/count1);
}
float student1::average13()
{
return(sum13/count1);
}
float student1::max11()
{
if(max1<c)
max1=c;
return max1;
}
float student1:: max12()
{
if(max2<gaoshu)
max2=gaoshu;
return max2;
}
float student1:: max13()
{
if(max3<dawu)
max3=dawu;
return max3;
}
float student1:: min11()
{
if(min1<c)
min1=c;
return min1;
}
float student1:: min12()
{
if(min2<gaoshu)
min2=gaoshu;
return min2;
}
float student1:: min13()
{
if(min3<dawu)
min3=dawu;
return min3;
}
float student1::sum11=0;
float student1::sum12=0;
float student1::sum13=0;
int student1::count1=0;
float max1=0,max2=0,max3=0;
float min1=0,min2=0,min3=0;
float cpp=0,shu=0,wu=0;
int main()
{
void change(student1 *p1);
int n,i=1;char mark='Y',r;
student1 *p,*k1;
p=new student1;
for(n=1;mark=='Y';n++)
{
p->next=new student1;
change(p);
cout<<"共输入了"<<n<<"个学生,继续输入请按Y,停止输入请按N :";
cin>>r;
mark=r;
k1=p;
}k1=NULL;
cout<<"**********共计"<<n-1<<"个学生************"<<endl;
return 0;
}
void change(student1 *p1)
{
int a;
cout<<"请选择输入:理科按1"<<endl;
cin>>a;
if(a==1)
{
cout<<"***********请修改该理工科学生信息************"<<endl;
cout<<"请输入学号:";
cin>>p1->n;
cout<<"请输入姓名:";
cin>>p1->na;
cout<<"请输入性别:";
cin>>p1->s;
cout<<"请输入该理工科学生成绩:";
cout<<"请输入c++成绩:";
cin>>p1->cpp;
cout<<"请输入高数成绩:";
cin>>p1->shu;
cout<<"请输入大物成绩:";
cin>>p1->wu;
cout<<"**************恭喜该生信息修改完成*****************"<<endl;
p1=p1->next;
}
}
这是为什么啊? 展开
展开全部
float student1::sum11=0;
float student1::sum12=0;
float student1::sum13=0;
int student1::count1=0;
//看到这几行初始化了么,类里面的静态变量都要预先初始化,
static float c;
static float gaoshu;
static float dawu;
static int count1;
static float sum11;
static float sum12;
static float sum13;
static float max1,max2,max3;
static float min1,min2,min3;
//这些全部都要初始化,像上边写的一样
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |