I am getting an error saying expected primary expression before void. This is my assignment. Hopefully I am doing this right but I am having trouble with this error. Any help would be appreciated
Write a main function that does the followings:
--- Create an empty vector of Student class (see code above).
--- Add 4 Student objects to the vector using the push_back() method.
--- Use a loop to show GPAs of 4 objects.
--- Insert a new Student object in the middle of the vector.
--- Use a loop to show GPAs of 5 objects.
I can't even figure out what you are doing here. getGPA() belongs to the Student class. Since you have a vector of them, and an iterator, you really want to reference using the iterator. You also can't pass cout anything from a void function. it->getGPA(); Will do what you want, which is print the student's GPA. You are also using a for loop to iterate through the vector, so you don't need to print the GPA 4 times per iteration.
*it = Student(44.9);
This is not inserting a new student into the vector, rather replacing an existing one. You should use s.insert(it,Student(44.9))
I suggest you just go error-by-error and try to fix it, then post again if you get stuck