jeudi 27 avril 2017

undefined reference to `displayForStudent(int, int const*, double const*, int)' collect2.exe: error: ld returned 1 exit status

I keep getting this error int he main function " undefined reference to `displayForStudent(int, int const*, double const*, int)'collect2.exe: error: ld returned 1 exit status." Any help with fixing this would be appreciated.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

using namespace std;

// Function prototypes
int readFile(const string &fileName, int studentId[], double grades[],          int maxGrades);
double minimumGrade(const double grades[], int numberGrades);
void displayForStudent(int id, const int studentId[], const double     grades[], int numberGrades);


int main()
{

    // this will contain the actual number of grades read in
    //  from the input file
    int numberGrades;
    // constant declaration
    const int MAX_GRADES = 20;


    // array declarations
    int studentId[MAX_GRADES];
    double grades[MAX_GRADES],
                minGrade ;

   // input file name
    string inputFileName;

    cout <<
       "Enter the file name to be read or hit enter to exit"
       << endl;
   getline(cin, inputFileName);

  while (inputFileName != "")
   {
    // go read the file and fill in the student id
    //  and grades array.
    // the return value is the actual number read in.
    numberGrades = readFile(inputFileName, studentId, grades,   MAX_GRADES);

    if (numberGrades == 0)
    {
        int num = 4;

        // output a message and return with a value of 4.
        // there were no grade records
        cout << "There are no grade records\n";
        return num;
    }
    else
    {
        // display the number of grade records read in
        cout << "There are " << numberGrades
                << " grade records\n";


        // output numbers in the format: xx.xx
        cout << fixed << setprecision(2);
        minGrade = minimumGrade(grades, numberGrades);
        // calculate and display the minimum grade
        cout << "Minimum grade is " << minGrade << endl;

        //  cout << "Maximum grade is " <<
        //       maximumGrade(grades, numberGrades) << endl;

        // calculate and display the average grade
        // Part 2 – comment out the next statement
        // for part 1.
        //  cout << "Average grade is " <<
        //      averageGrade(grades, numberGrades) << endl;

        // for student ids 1 through 6 display the
        //  grades and average for that student
        for (int id = 1; id <= 6; id++)
        {
            // call displayForStudent to display grades
            // and average for this student
            displayForStudent(id, studentId, grades, numberGrades);
        }
    cout << "Enter the file name to be read or hit enter to exit"<< endl;
    getline(cin, inputFileName);
       }
    }

// return to operating system
return 0;
}

Aucun commentaire:

Enregistrer un commentaire