C++类和对象,一个问题始终无法找到错误所在?望各位高手指点

来源:百度知道 编辑:UC知道 时间:2024/07/01 04:14:44
我的程序如下:
#ifndef Student_H
#define Student_H
class Student
{
private:
int reg[10];
char name[10];
double math;
double eng;
double comp;
public:
double sum();
double average();
void print();
int get_reg_num();
void set_stu_inf();
};
#endif
#include <iostream>
#include "student.h"
using namespace std;
double Student::sum()
{
return math+eng+comp;
}
double Student::average()
{
return ((math+eng+comp)/3.0);
}
void Student::print()
{
cout<<"学生个人信息:"<<endl;
cout<<" 姓 名:"<<name[10]<<endl;
cout<<" 注 册 号:"<<reg[10]<<endl;
cout<<" 数学成绩:"<<math<<endl;
cout<<" 英语成绩:"<<eng<<endl;
cout<<" 计算机成绩:"

stu[i].set_stu_inf(r[10],n[10],m,e,c);
把r[10]与n[10]改成r,n

void set_stu_inf();
上面是你的声明,函数体没有任何参数
下面是你的函数,却冒出来5个参数
void Student::set_stu_inf(int r[10],char n[10],double m,double e,double c)
{
reg[10]=r[10];
name[10]=n[10];
math=m;
eng=e;
comp=c;
}

编译错误:error C2660: 'set_stu_inf' : function does not take 5 parameters

翻译:错误C2660: 'set_stu_inf' : 函数没有5个参数。