各位大虾,问一下这代码有什么错误。
#include<iostream.h>//类界面
class STUDENT {
public:
STUDENT(char name[15],char number[9],char major[15]);//学生的名字,学号和专业
~STUDENT();
char name[15],number[9],major[15];
};
class ATTENDANCE{
public:
float att_mark(int zhdfsh1,int dmcsh,int ddcsh);//(占的分数,点名次数,到的次数)
ATTENDANCE();
~ATTENDANCE();
int zhdfsh1,dmcsh,ddcsh;
};
class HOMEWORK{
public:
float home_mark(int zhdfsh2,char zyqk);//(占的分数,作业情况)
HOMEWORK();
~HOMEWORK();
int zhdfsh2;
char zyqk;
};
class MID_EXAM{
public:
float mid_mark(int zhdfsh3,float midmark);//(期中考占的分数,考得的成绩)
MID_EXAM();
~MID_EXAM();
int zhdfsh3;
float midmark;
};
class FINAL_EXAM{
public:
float final_mark(int zhdfsh4,float fimark);
FINAL_EXAM();
~FINAL_EXAM();
int zhdfsh4;
float fimark;
};
class STUDENT_MARK:public STUDENT,public ATTENDANCE,public HOMEWORK,public MID_EXAM,public FINAL_EXAM{
public:
int total_mark(float att_mark,float home_mark,float mid_mark,float final_mark);
STUDENT_MARK();
~STUDENT_MARK();
float att_mark;
float home_mark;
float mid_mark;
float final_mark;
};
//类实现
STUDENT::STUDENT(char name[15],char number[9],char major[15])
{
cout<<"Student's name is"<<name[15]<<"\n";
cout<<"Student's number is"<<number[9]<<"\n";
cout<<"Student's major is"<<major[15]<<"\n";
return;
}
float ATTENDANCE::att_mark(int zhdfsh1,int dmcsh,int ddcsh)
{
return (float) zhdfsh1*ddcsh/dmcsh;
}
float HOMEWORK::home_mark(int zhdfsh2,char zyqk)
{
switch (zyqk){
case 'a':return (float) zhdfsh2;break;
case 'b':return (float)0.9*zhdfsh2;break;
case 'c':return (float)0.8*zhdfsh2;break;
case 'd':return (float)0.7*zhdfsh2;break;
case 'e':return (float)0.6*zhdfsh2;break;
}
}
float MID_EXAM::mid_mark(int zhdfsh3,float midmark)
{
return zhdfsh3*midmark;
}
float FINAL_EXAM::final_mark(int zhdfsh4,float fimark)
{
return zhdfsh4*fimark;
}
int STUDENT_MARK::total_mark(float att_mark,float home_mark,float mid_mark,float final_mark)
{
return (int)att_mark+home_mark+mid_mark+final_mark;
}
STUDENT_MARK::STUDENT_MARK()
{
return;
}
STUDENT_MARK::~STUDENT_MARK()
{
return;
}
void main()
{
STUDENT_MARK obj_student;
int zhdfsh1,zhdfsh2,zhdfsh3,zhdfsh4,dmcsh,ddcsh,total_mark,totalmark;
char name[15],number[9],major[15],zyqk;
float att_mark,home_mark,mid_mark,final_mark;
cout<<"请输入学生名字(英文)、学号和专业(英文)。\n";
cin>>obj_student.name[15]>>obj_student.number[9]>>obj_student.major[15];
cout<<"请输入点名占的分数、点名次数和已到的次数。\n";
cin>>obj_student.zhdfsh1>>obj_student.dmcsh>>obj_student.ddcsh;
cout<<"请输入作业占的分数和作业情况。\n";
cout<<"(作业情况等级为a~e,为100%~60%,一一对应。\n";
cin>>obj_student.zhdfsh2>>obj_student.zyqk;
cout<<"请输入期中考占的分数和考得的成绩。\n";
cin>>obj_student.zhdfsh3>>obj_student.midmark;
cout<<"请输入期末考占的分数和考得的成绩。\n";
cin>>obj_student.zhdfsh4>>obj_student.fimark;
totalmark=obj_student.total_mark(obj_student.att_mark,obj_student.home_mark,obj_student.mid_mark,obj_student.final_mark);
cout<<"该学生最终成绩为:\n"<<totalmark<<endl;
}