I keep getting compiler errors. Could anyone help please? Thanks
This is the error message:
F:\DPR226\Homework\Student\main.cpp In function `int main(int, char**)':
39 F:\DPR226\Homework\Student\main.cpp invalid conversion from `int' to `int*'
39 F:\DPR226\Homework\Student\main.cpp initializing argument 4 of `void Student::setStudent(std::string, std::string, std::string, int*)'
F:\DPR226\Homework\Student\Makefile.win [Build Error] [main.o] Error 1
// main.cpp
#include <cstdlib>
#include <iostream>
#include "Student.h"
using namespace std;
int main(int argc, char *argv[])
{
string id;
string fName;
string lName;
int score[SCORE];
double average;
char grade;
int numOfStu = 0;
Student student[SIZE];
while( numOfStu < SIZE && !cin.eof())
{
cout << "Enter student " << Student :: getNumOfStu()+1 << " id, enter ctrl-z to quit: ";
getline(cin, id);
if(!cin.eof())
{
cout << "Enter first name: ";
getline(cin, fName);
cout << "Enter last name: ";
getline(cin, lName);
cout << "Enter " << SCORE <<" test score: ";
for (int i = 0; i < SCORE; i++)
{
cin >> score[i];
}
cin.ignore();
}
system("cls");
student[numOfStu].setStudent(id, fName, lName, score[SCORE]);
student[numOfStu].calculate();
student[numOfStu].print();
numOfStu++;
}
system("PAUSE");
return EXIT_SUCCESS;
}
//Student.h
#ifndef STUDENT
#define STUDENT
#include <string>
using namespace std;
const int SIZE =3, SCORE = 5;
class Student
{
private:
string id;
string fName;
string lName;
int score[SCORE];
double average;
char grade;
static int numOfStu;
public:
Student();
Student(string idIn, string fNameIn, string lNameIn,
int scoreIn[]);
void setStudent(string idIn, string fNameIn, string lNameIn,
int scoreIn[]);
string getID() {return id;}
string getFName() {return fName;}
string getLName() {return lName;}
int getScore() {return score[SCORE];}
void calculate();
static int getNumOfStu();
void print() const;
};
#endif
// Student.cpp
#include <cstdlib>
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
#include "Student.h"
int Student :: numOfStu = 0;
Student :: Student()
{
id = " ";
fName = " ";
lName = " ";
for(int i = 0; i < SCORE; i++)
{
score[i] = 0;
}
}
Student :: Student(string idIn, string fNameIn, string lNameIn,
int scoreIn[])
{
setStudent(idIn, fNameIn, lNameIn, scoreIn[]);
numOfStu++;
}
void Student :: setStudent(string idIn, string fNameIn, string lNameIn,
int scoreIn[])
{
id = idIn;
fName = fNameIn;
lName = lNameIn;
for(int i = 0; i < SCORE; i++)
{
score[i] = scoreIn[i];
}
}
void Student :: calculate()
{
int totalScore = 0;
for(int i = 0; i < SCORE; i++)
totalScore += score[i];
average = totalScore / SCORE;
if(average >= 90)
grade = 'A';
else if(average >= 80)
grade = 'B';
else if(average >= 70)
grade = 'C';
else if(average >= 60)
grade = 'D';
else
grade = 'F';
}
int Student :: getNumOfStu()
{
return numOfStu;
}
void Student :: print() const
{
cout << left << setw(5) << i << setw(6) << fName << setw(6) << lName
<< right << setw(8);
for(int i = 0; i < SCORE; i++)
{
cout << score[i] << setw(8);
}
cout << fixed << showpoint << setprecision(1);
cout << average << setw(8) << grade << endl;
}