My program isn't compiling

Hi I really need help finding the error in the following program:

I've been trying to figure out what's wrong with it for the past couple of days and couldn't... any help would be greatly appreciated.

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

class GradeOutput
{
public:
const static int students = 10;
const static int tests = 3;

GradeOutput (string, const int [][tests]);

void sortGrades();
double getAverage (const int[], const int);
void outputGrades();
private:
int grades[students][tests];
};

GradeOutput::GradeOutput (string, const int gradesArray[][tests])
{
for (int student = 0; student < students; student++)
for (int test = 0; test < tests; test++)
grades[students][tests] = gradesArray[students][tests];
}

double GradeOutput::getAverage (const int gradesSet[], const int grades)
{
int total = 0;
for (int grade = 0; grade < grades; grade++)
total += gradesSet[grade];
return static_cast<double>(total)/grades;
}

void GradeOutput::sortGrades()
{
string student[students];
for(int i =0; i <=9; i++)
{
for(int j=i+1; j<=3;j++)
{
if(student[i]>student[j])
{
string temp;
temp=student[i];
student[i]=student[j];
student[j]=temp;
}
}
}
}

void GradeOutput::outputGrades()
{
cout << "\nThe grades are:\n\n";
cout << " ";
for (int test = 0; test < tests; ++test)
cout << "Test" << test + 1 << " ";
cout << "Average" << endl;
for (int student = 0; student < students; ++student)
{
cout << "Student" << setw(2) << student + 1;
for (int test = 0; test < tests; ++test)
cout << setw(8) << grades[student][test];
double average = getAverage(grades[student], tests);
cout << setw(9) << setprecision(2) << fixed << average << endl;
}
}


int main()
{
const int students = 10;
string student[students];
const int tests = 3;
int test[tests];

for (int i = 0; i <=9; i++)
{
cout << "Please enter the name of student " << i+1 << ": ";;
cin >> student[i];
for (int j = 0; j <= 2; j++)
{
cout << "Please enter grade " << j+1 << " of this student: ";
cin >> test[j];
}

GradeOutput list();
list.sortGrades();
list.outputGrades();
}

system ("pause");
return 0;
}
Last edited on
In the following line you're trying to instantiate GradeOutput and call it's default constructor, but you have no default constructor.

 
GradeOutput list();


PLEASE USE CODE TAGS (the <> formatting button) when posting code.
Topic archived. No new replies allowed.