定义了结构体
typedef struct Contacts
{
char id[10]; //学号
char name[10]; //姓名
char sex[10]; //性别
char class_number[10]; //班级
char class_name1[30]; //科目1
char class_name2[30]; //科目2
char class_name3[30]; //科目3
char score[30]; //总成绩
char score1[30]; //成绩1
char score2[30]; //成绩2
char score3[30]; //成绩3
}Student;
运用链表存储的,当我总成绩=成绩1+2+3时报错,改为int型其他地方又报错。
void SingleOut(Student e)
{
e.score=e.score1+e.score2+e.score3;
cout<<"学号、姓名、性别、班级、科目1、成绩、科目2、成绩、科目3、成绩:\n";
cout<<setiosflags(ios_base::left)<<" "<<e.id
<<" "<<e.name<<" "<<e.sex<<" "<<e.class_number
<<" "<<e.class_name1<<" "<<e.score1
<<" "<<e.class_name2<<" "<<e.score2
<<" "<<e.class_name3<<" "<<e.score3
<<resetiosflags(ios_base::left)<<endl;
cout<<"学生总成绩为:"<<e.score;
}
|254|error: invalid operands of types 'char [30]' and 'char [30]' to binary 'operator+'|
上网搜索原因是char类型不能相加,采取score-0的方法转换后仍报错|254|error: invalid operands of types 'char*' and 'char*' to binary 'operator+'|
就把成绩求和加起来,怎么这么折磨人
把score的类型改成int不用数组