I am trying to read from a which first input is how many records are in. The rest is the id of the student, first name, last name, and then exam grade. However, I can not get the input from the file into the array. Any help from anyone?
you set up a constructor in your Student class but you never defined it.
You would need to do something like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class Student
{
private:
public:
int id, grade;
string firstName;
string lastName;
Student(int, string, string, int);
};
Student::Student(int a, string b, string c, int d){
id = a;
firstName = b;
lastName = c;
grade = d;
}
but if you aren't going to have any private variables you may as well use a struct instead of a class. A struct is pretty much the same thing as a class just that all the variables are public by default instead of private like a class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
struct Student
{
int id, grade;
string firstName;
string lastName;
Student(int, string, string, int);
};
Student::Student(int a, string b, string c, int d){
id = a;
firstName = b;
lastName = c;
grade = d;
}
Thank you! I have now defined the constructor.This is for an assignment and it needs to be in a class. I just have no idea on how to go about setting all of this into an array.