函数illegal 怎么解决啊!请高手们赐教哦~
#include <iostream>#include <string>
using namespace std;
class achievement
{public:
int subject1;
int subject2;
int subject3;
int subject4;
};
class student
{ public:
string id;
string name;
achievement ach;
inline void set_student();
};
inline void student::set_student()
{cin>>id;
cin>>name;
cin>>ach.subject1;
cin>>ach.subject2;
cin>>ach.subject3;
cin>>ach.subject4;
}
int main()
{int i,j,k,t;
i=j=k=0;
student s[100];
for(k=0;k<100;k++)
{s[i].set_student();}
int sum[100],ave[100];
void sum_sum(int sum[],int k);//函数声明 求和
sum_sum(sum,100);
void ave_sum(int sum[],int k);//函数声明 求平均数
ave_sum(sum,100);
for(j=0;j<100;j++)
{cout<<s[j].id<<s[j].name<<endl;
cout<<s[j].ach.subject1<<s[j].ach.subject2<<endl;
cout<<s[j].ach.subject3<<s[j].ach.subject4<<endl;
}
/*********************/ //排序用冒泡
for(i=0;i<=100;i++)
for(j=0;j<=100-i;j++)
{if(sum[i]>sum[i+1])
{t=sum[i];sum[i]=sum[i+1];sum[i+1]=t;}
for(j=0;j<100;j++)
{cout<<s[j].id<<s[j].name<<endl;
cout<<s[j].ach.subject1<<s[j].ach.subject2<<endl;
cout<<s[j].ach.subject3<<s[j].ach.subject4<<endl;
}
/*********************/ //输入学生学号 输出成绩
string id;
for(k=0;k<100;k++)
{
cin>>id;
for(j=0;j<100;j++)
{if(id==s[j].id)break;}
cout<<s[j].id<<s[j].name<<endl;
cout<<s[j].ach.subject1<<s[j].ach.subject2<<endl;
cout<<s[j].ach.subject3<<s[j].ach.subject4<<endl;
}
return 0;
}
void sum_sum(int sum[],int k) //函数定义1
{int n;
for(n=0;n<=k;n++)
{sum[n]=s[n].ach.subject1+s[n].ach.subject2+
s[n].ach.subject3+s[n].ach.subject4;
}
}
void ave_sum(int sum[],int k) //函数定义2
{int n;
for(n=0;n<=k;n++)
{
ave[n]=sum[n]/4;
}
}
}
D:\Microsoft Visual C++ 6.0 简体中文企业版\题目.cpp(69) : error C2601: 'sum_sum' : local function definitions are illegal
D:\Microsoft Visual C++ 6.0 简体中文企业版\题目.cpp(76) : error C2601: 'ave_sum' : loca
这个原因是什么 请高手指教!!!!!