have gotten this far, but somehow i keep getting an invalid error , please help. i am supposed to display the highest gpa score along with the name , but that is the part i cannot seem to get.
#include<iostream>
#include<string>
using namespace std;
class Student
{
private:
string name;
double gpa;
int rank;
highestScore is likely to have junk that is then never set to anything valid meaning learner[highestScore].getName will be out of scope...and getName is a function so learner[highestScore].getName()
(from reading the code, so I might have missed something)
Always pay attention to compiler errors and warnings.
uninitialized local variable 'studRank' used main.cpp 89
expression must have integral or unscoped enum type main.cpp 100
subscript is not of integral type main.cpp 100
Basically it means that you can't use a double as an array index.
To get the index of the best student use:
1 2 3 4 5 6 7 8 9 10 11
highestScore = learner[0].getGpa();
int highestIndex = 0;
for (int x = 1; x < 3; x++)
{
if (learner[x].getGpa() > highestScore)
{
highestIndex = x;
}
}
cout << "winner is:" << learner[highestIndex].getName() << "\n" << endl;