救助!c++程序错误分析
本人有一段c++程序,不知编译后的错误的意思,请大家帮忙,谢谢。程序的目的是求五位学生四门课程的总分以及平均分。程序如下:
#include <iostream.h>
class student
{public:
student(char *p[10],int x1,int x2,int x3,int x4)
{name=p;
s[0]=x1;
s[1]=x2;
s[2]=x3;
s[3]=x4;}
int sum(int x1,int x2,int x3,int x4)
{return (x1+x2+x3+x4);}
private:
int s[4],char *name[10];};
int aver(int x1,int x2,int x3,int x4)
{return (x1+x2+x3+x4)/4;}
int maxsum(student a[5])
{int temp;
temp=a[0].sum(int x1,int x2,int x3,int x4);
for(int i=1;i<=3;i++)
{if (temp<a[i].sum(int x1,int x2,int x3,int x4))
temp=a[i].sum(int x1,int x2,int x3,int x4);
return temp;}
void main
{student *a;
a=new student[5];
for(int i=0;i<5;i++)
{
{for(int j=0;j<4;j++)
cin>>s[j]>>',';}
cin>>*name;
cout<<endl;
}
for(int i=0;i<5;i++)
{cout<<i<<"every student sum scores=";
cout<<a[i].sum(int x1,int x2,int x3,int x4)<<' ';
cout<<endl;}
for(int i=0;i<4;i++)
{cout<<"averscore"<<i<<"=";
cout<<aver(a[0].s[i],a[1].s[i],a[2].s[i],a[3].s[i])<<endl;}
cout<<"maxsum student score="<<maxsum<<endl;
delete []a;}
编译后错误如下:
--------------------Configuration: Cpp555class - Win32 Debug--------------------
Compiling...
Cpp555class.cpp
E:\Debug\Cpp555class.cpp(13) : warning C4518: 'char ' : storage-class or type specifier(s) unexpected here; ignored
E:\Debug\Cpp555class.cpp(13) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
E:\Debug\Cpp555class.cpp(4) : error C2440: '=' : cannot convert from 'char *[]' to 'int *[10]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
E:\Debug\Cpp555class.cpp(18) : error C2144: syntax error : missing ')' before type 'int'
E:\Debug\Cpp555class.cpp(18) : error C2660: 'sum' : function does not take 0 parameters
E:\Debug\Cpp555class.cpp(18) : error C2059: syntax error : ')'
E:\Debug\Cpp555class.cpp(20) : error C2144: syntax error : missing ')' before type 'int'
E:\Debug\Cpp555class.cpp(20) : error C2660: 'sum' : function does not take 0 parameters
E:\Debug\Cpp555class.cpp(20) : error C2059: syntax error : ')'
E:\Debug\Cpp555class.cpp(24) : error C2182: 'main' : illegal use of type 'void'
E:\Debug\Cpp555class.cpp(24) : error C2601: 'main' : local function definitions are illegal
E:\Debug\Cpp555class.cpp(24) : error C2063: 'main' : not a function
E:\Debug\Cpp555class.cpp(42) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
Cpp555class.exe - 11 error(s), 2 warning(s)