0

I understand that this question has been asked, but no solutions pertained to my problem. This is the exact error given on compile.

Error   1   error LNK2019: unresolved external symbol "void __cdecl fileManagment(class collegeStudent * const,int)" (?fileManagment@@YAXQAVcollegeStudent@@H@Z) referenced in function _main   
C:\Users\zacharybresser\Downloads\CollegeDiplomas\CollegeDiplomas\CollegeDiplomas\CollegeDiplomas.obj   CollegeDiplomas

It mentions my main .cpp file which is included here

main.cpp

#include "stdafx.h"
#include <iostream>
#include <string>
#include "CollegeStudent.h"
#include "StringTokenizer.h"
#include "fileManagement.h"
#include "date.h"

using namespace std;

const int MAX_GRADUATES = 20;

int main()
{
    int numElems = 0;
    collegeStudent graduates[MAX_GRADUATES];
    fileManagment(graduates, numElems);

    int year;
    year = graduates[0].getYear();
    cout << year;
    system("pause");
}

It also mentions the function fileManagement which is in this .cpp file:

fileManagement.cpp

#include "stdafx.h"
#include <iostream>
#include "fileManagement.h"
#include "StringTokenizer.h"
#include "date.h"
#include <fstream>
#include <string>

using namespace std;

//Deals with the input from file
void fileManagement(collegeStudent graduates[], int& numElems)
{
    //Variable Declarations
    ifstream fileIn;
    string inString;
    int index = 0;

    fileIn.open("gradInfo.txt");

    //IF file opened
    if (fileIn.is_open())
     {
        int counter = 0;
        getline(fileIn, inString); // Priming Read
        while (!fileIn.eof())
        {
            graduates[index] = setFromCoded(inString);
            getline(fileIn, inString);
            index++;
        }
        numElems = index;
    }
}

 collegeStudent setFromCoded(string inString)
{
    string tempFirst, tempLast, tempDate, tempMiddle, tempDegree,
        tempCollege;
    int tempMonth, tempDay, tempYear;
    collegeStudent outReturn; // Object for return value

    //Use stringtokenizer
    StringTokenizer tokenizer(inString, ',');

    //Get Tokens for all the strings
    tempCollege = tokenizer.getStringToken();
    tempLast = tokenizer.getStringToken();
    tempFirst = tokenizer.getStringToken();
    tempMiddle = tokenizer.getStringToken();
    tempDegree = tokenizer.getStringToken();
    tempDate = tokenizer.getStringToken();

    //Retrieve the date components from the file
    StringTokenizer dateTokens(tempDate, '/');
    tempMonth = dateTokens.getIntToken();
    tempDay = dateTokens.getIntToken();
    tempYear = dateTokens.getIntToken();
    dateObject workDate(tempMonth, tempDay, tempYear); //Instantiate Date Object

    //Prepare record for return
    outReturn.setFirst(tempFirst);
    outReturn.setLast(tempLast);
    outReturn.setMiddle(tempMiddle);
    outReturn.setCollege(tempCollege);
    outReturn.setDay(tempDay);
    outReturn.setMonth(tempMonth);
    outReturn.setYear(tempYear);
    outReturn.setDegree(tempDegree);
    return outReturn;
}

Does anyone see how that error is popping up? I just cannot figure it out.

Edit: This is the header file for the fileManagment function:

fileManagment.h

#ifndef INCLUDED_FILEMANAGEMENT_RESTRICT
#define INCLUDED_FILEMANAGEMENT_RESTRICT

#include "CollegeStudent.h"

//This function is for the management of input from the file
void fileManagment(collegeStudent [], int);
collegeStudent setFromCoded(string);


#endif //INCLUDED_FILEMANAGEMENT_RESTRICT
user2311215
  • 39
  • 1
  • 3
  • 10
  • 1
    The definition of `fileManagement()` does not match its declaration. The error message quite clearly indicates that the signature is different from that of the function you show here. – Cameron Feb 09 '15 at 19:20
  • How does the declaration of `fileManagement()` from the header file actually look like? – πάντα ῥεῖ Feb 09 '15 at 19:20
  • From the linker error message, it appears that the declaration of `fileManagement` is `void fileManagement(collegeStudent graduates[], int numElems);`, which is different than how it is implemented. – R Sahu Feb 09 '15 at 19:24
  • how is it different though. It takes two parameters a array of objects and an integer value the same way that it is called. I will add the header file. – user2311215 Feb 09 '15 at 21:07

0 Answers0