LNK2019 and LNK 1120 Error

I have an assignment for a class where the program assigns class names and grades to an array of classes, and in the "readGrade" function I get two link errors. The first is :

Error 1 error LNK2019: unresolved external symbol "void __cdecl readGrades(class std::basic_ifstream<char,struct std::char_traits<char> > &,class course_grade *)" (?readGrades@@YAXAAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@PAVcourse_grade@@@Z) referenced in function _main C:\Users\Mike\Documents\Visual Studio 2013\Projects\hw 8\hw 8\hw 8.obj hw 8

and the second:

Error 2 error LNK1120: 1 unresolved externals C:\Users\Mike\Documents\Visual Studio 2013\Projects\hw 8\Debug\hw 8.exe 1 1 hw 8

I assume that the second one will go away once the first is taken care of.

Here is the code...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*This program creates a class that contains the name
	of a student, the course, and the course grade.
*/

#include "stdafx.h"
#include <iostream>
using namespace std;
#include <iomanip>
#include <fstream>
#include <string>

const unsigned short int MAXELS = 10;

class course_grade{
private:
	string course;
	string grade;
public:
	course_grade();
	course_grade(string courseIn, string gradeIn);

	void setCourseGrade(string, string);
	void setCourse(string);
	void setGrade(string);

	void getCourseGrade();
	void getCourse();
	void getGrade();
};

void OpenFile(ifstream&, string);
void readGrades(ifstream&, course_grade *);
void CloseFile(ifstream&, string);

int main()
{
	int n = 0;
	ifstream inFile;
	string fileName = "students.txt";
	course_grade myGrades[MAXELS], *myGradesPtr = myGrades;

	//open the file
	OpenFile(inFile, fileName);

	//read the file into an array
	readGrades(inFile, myGradesPtr);

	//close the file
	CloseFile(inFile, fileName);

	return 0;
}

course_grade::course_grade()
//0 parameter constructor
{
	setCourseGrade("N/A", "0");								
}

course_grade::course_grade(string courseIn, string gradeIn)
{//double parameter contructor

	course = courseIn;
	grade = gradeIn;

}

void course_grade::setCourseGrade(string inCourse, string inGrade)
{//sets the course and grade for the student

	course = inCourse;
	grade = inGrade;

}

void course_grade::setCourse(string inCourse)
{//sets the course for the student

	course = inCourse;

}

void course_grade::setGrade(string inGrade)
{//sets the grade for the student

	grade = inGrade;

}

void course_grade::getCourseGrade()
{//dsiplays the coure and grade

	cout << "The grade for the course " << course << "is: " << grade << endl;

}

void course_grade::getCourse()
{//gets the course for the student

	cout << "The course is " << course << endl;
}

void course_grade::getGrade()
{//gets the grade for the course

	cout << "The grade is " << grade << endl;

}

void OpenFile(ifstream& Infile, string filename)
{ //function that opens file, catches any errors
	try //try to open the file
	{
		Infile.open(filename); // open the file

		if (Infile.fail()) //if it fails, thow an exception
		{
			throw filename;
		}
		else
		{
			cout << "The input file has been opened" << endl;

		}
	}
	catch (string filename) //catch the exception
	{
		cout << "The file '" << filename << "' was not opened.\nPlease make sure the file exists in the directory!\n";
		cout << "The program will now terminate. Have a nice day!\n";
		system("pause");
		exit(1); //exit the program
	}
}

void ReadGrades(ifstream& gradeInFile, course_grade *gradeArray)
{ //reads grades from file, assigns them to the array
	string name, courseName, score;

	cout << "The readGrades funciton is working....\n\n";
	
	gradeInFile >> name >> courseName >>  score;

	gradeArray->setCourseGrade(courseName, score);

	cout << "Here is the entire list for: " << name << endl << endl;
	cout << "COURSE NAME         SCORE\n";
	cout << "------------------------------------------\n";

	cout << setw(10) << std::left << name << setw(5) << std::right << score << endl;

	gradeArray++;

	//read and assign information from file until EOF
	while (gradeInFile >> courseName >> score)
	{

		gradeArray->setCourseGrade(courseName, score);

		cout << setw(10) << std::left << name << setw(5) << std::right << score << endl;

		gradeArray++;
	}


	cout << endl;
	system("pause");
}

void CloseFile(ifstream& InFile, string FileName)
{//closes the file for future use
	InFile.close();
	cout << "\nThe file '" << FileName << "' has been closed.\n\n";
	system("pause");
}


The function headers match up with the functions, so I'm not sure whats wrong,

Thanks!
closed account (3hM2Nwbp)
readGrades != ReadGrades

Those little typos are buggers to debug, eh?

@ line 135, change ReadGrades -> readGrades to be more specific
Last edited on
I feel so dumb now lol, thanks!!
Topic archived. No new replies allowed.