This is the error I get

As5.obj : error LNK2019: unresolved external symbol "void __cdecl DisplayNames(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?DisplayNames@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00@Z) referenced in function _main
C:\Users\Daniel\Desktop\Programming I\As5\Debug\As5.exe : fatal error LNK1120: 1 unresolved externals

I have no clue what it means.

This is my entire program, the only thing I know is that it's caused by the function DisplayNames, or the variables in it.
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
#include <iostream>
#include <string>

using namespace std;

void GetName(const string, const int, string&);
void DisplayNames(string, string, string);

void main()
{
	const int    MAX_FIRST = 30;
	const int    MAX_LAST = 25;
	const int    MAX_LOCATION = 20;
	const int    MAX_MONTHS = 12;
	const string FIRST_QUESTION    = { "First Name (25 chars max, type \"quit\" to stop): " };
	const string LAST_QUESTION     = { "Last Name  (30 chars max, type \"quit\" to stop): " };
	const string LOCATION_QUESTION = { "Location   (20 chars max, type \"quit\" to stop): " };
	string       firstName = "";
	string       lastName = "";
	string       locationName = "";
	char         rating[MAX_MONTHS];
	int          ratingNumber[MAX_MONTHS];

	while (true)
	{
		GetName(LAST_QUESTION, MAX_LAST, lastName);
		GetName(FIRST_QUESTION, MAX_FIRST, firstName);
		GetName(LOCATION_QUESTION, MAX_LOCATION, locationName);

		DisplayNames(lastName, firstName, locationName);

	}

}

void GetName(const string question, const int MAX, string &name)
{
	int count;

	do
	{
		cout << question;
		cin  >> name;

		name[0] = toupper(name[0]);

		for (count = 1; count < name.length(); count++)
		{
			name[count] = toupper(name[count]);
		}

	} while (name.length() > MAX || name.empty());

}

void DisplayName(string last, string first, string location)
{
	cout << "Last Name:  " << last << endl;
	cout << "First Name: " << first << endl;
	cout << "Location:   " << location << endl;
}
99 times out of 100, "unresolved external symbol" means you are calling a function that you never gave a body to.

In your case, you are calling DisplayNames (which is prototyped on line 7) -- however you never defined any body for that function.


Instead, you defined a body for "DisplayName" (note the subtle difference) on line 56.
Is it normal to be making such a mistake as a beginner?
I don't know that more experience necessarily makes one immune to typos in variable or function names, but when an error message like this comes up, you'll know more specific things you can check to fix the problem.
Topic archived. No new replies allowed.