Just curious, why are you doing this all in one file? It'd be much easier if you broke it up into a main.cpp, student.cpp, and student.h
Also, why are all of the data members like GPA, studentNumber, etc public? It's good practice to keep those private, and perhaps for the private data members use names like m_lastName, m_GPA, etc. Just something different so that way when you set up your constructor you can set it with statements like m_lastName = lastName (lastName being the info read in, being set to the private data member)
that said, I'm confused why you have something names "set_values" rather than an overloaded constructor
It'd be far easier to do something like this:
1 2 3 4 5 6 7 8 9
|
Student::Student(string lastName, string firstName, string middleName, string currentGrade, string Course, int studentNumber, double GPA){
m_lastName = lastName;
m_firstName = firstName;
m_middleName = middleName;
m_currentGrade = currentGrade;
m_Course = Course;
m_studentNumber = studentNumber;
m_GPA = GPA;
}
|
As you seem to be setting up the constructor like a function. Which isn't necessarily wrong, but with bigger codes it will confuse you and anyone looking at it. This approach allows you to simply declare it in main like this:
|
Student student2("Turnham","James","D", "A-","Programming II",12345,3.5);
|
The .set_values is unnecessary
Essentially you have your default constructor setup, but look
1 2 3
|
Student set_values(string, string, string, string, string, int, double);
~Student(); //destructor
void Display();
|
You have no actual constructor for this. Essentially what this line of your code is saying is:
1. Declare a data member of type Student named set_values with (these parameters)
which is not what you want to be doing. To set it up as a constructor, the name "set_values" is not needed at all. It could also be viewed as setting up a function that returns a value of Student, but I don't think that was the intention either.
Hopefully that wasn't too jumbled up and made some sense haha