没有与参数列表匹配的构造函数Student::Student
#include <iostream>#include<cstdio>
#include<cstdlib>
#include<Windows.h>
using namespace std;
class Student{
public:
int age;
char name[20];
int Chinese;
int English;
int Math;
Student(int age, char name[20], int Chinese, int English, int Math);
void WhileGetchar(char name[20]);
void PrintStudent();
};
Student::Student(int _age, char _name[20], int _Chinese, int _English, int _Math) {
age = _age;
name[20] = _name[20];
Chinese = _Chinese;
English = _English;
Math = _Math;
}
void Student::WhileGetchar(char name[20]) {
int i = -1;
while (name[i] != '\n') {
i++;
name[i] = getchar();
}
}
void Student::PrintStudent() {
cout << age << endl << name << endl << Chinese << endl << English << endl << Math << endl;
}
int main()
{
int age, Math, Chinese, English;
cin >> age >> Math >> Chinese >> English;
Student student(age,"**_***",Chinese,English,Math);//报错在这一行
student.WhileGetchar(student.name);
student.PrintStudent();
return 0;
}