#include <iostream.h>
class student
{
private:
char name[20];
char sex;
int num;
float aver;
float s1,s2,s3,s4;
public:
student(char n,char s,int u);
float average(float s1,float s2,float s3,float s4);
void show();
};
student::student(char n[20],char s,int u,float s_1,float s_2,float s_3,float s_4)
{
name[20]=n[20];
sex=s;
num=u;
s1=s_1;
s2=s_2;
s3=s_3;
s4=s_4;
}
float student::average()
{
aver=(s1+s2+s3+s4)/4;
}
void student::show()
{
cout<<"姓名:"<<name<<"性别:"<<sex<<"学号:"<<num<<"平均分:"<<aver<<endl;
}
void main()
{
student stu1("xiaoli",'M',1,80,90,70,60)
stu1.average();
stu1.show();
}
哪里错了
RockenRoll
相关分类