Good for listing the error message> I get the same:
a.cpp: In function 'void fillVector(std::vector<student>&)':
a.cpp:95:43: error: no matching function for call to 'student::student(std::__cxx11::string&, double&, int&, int&)'
student newStudent(name, gpa, year, rank);
^
a.cpp:15:3: note: candidate: student::student()
student()
^
a.cpp:15:3: note: candidate expects 0 arguments, 4 provided |
The error message is actually very specific: there is no function
student::student(string&, double, int, int)
.
Looking through your code there is exactly one constructor for
student
: a default constructor taking no arguments. The compiler even gives you line numbers:
Line 95: attempting to call a function (constructor) that does not exist
Line 15: here is the only constructor I could find.
There are two ways to fix it. Create your object and use the setters to set the various pieces of information:
95 96 97 98 99 100
|
student newStudent;
newStudent.setName(name);
newStudent.setGpa(gpa);
newStudent.setYear(year);
newStudent.setRank(rank);
newAllStudents.push_back(newStudent);
|
Or add the desired constructor:
15 16 17 18 19 20 21 22 23 24 25
|
student()
{
// snip
}
student(const std::string& name, double gpa, int year, int rank)
{
this->name = name;
this->gpa = gpa;
this->year = year;
this->rank = rank;
}
|
A similar issue exists for the error about "getname", etc. You
do have functions named "getName", etc though.
Hope this helps.