Which symbols is the "unresolved external symbol"?

I'm working on a program to take in an object with a name(string) and a number(double),put them into an array of objects, sort the objects by the number, and then output a list of names. When I try to output, though, it tells me "unresolved external symbol". I think it points to the output operator in the code below, but I'm not sure. Along that line of thought, I tried to overload the operator, but that only caused more problems and didn't seem to solve the original issue. Can anyone tell me where I'm going wrong? I put the function I think I'm having issues with, and the function that it calls, below.

Edit: Here are the error messages I'm getting:

Error LNK1120 1 unresolved externals Combat Sorter C:\Users\theog\OneDrive\The Gray System Work Stuff\Combat Sorter\Debug\Combat Sorter.exe 1

Error LNK2001 unresolved external symbol "class actor::Actor * aInitOrder" (?aInitOrder@@3PAVActor@actor@@A) Combat Sorter C:\Users\theog\OneDrive\The Gray System Work Stuff\Combat Sorter\Combat Sorter\Main.obj 1

Thank you for the help.

1
2
3
4
5
6
7
8
9
10
11
12
13
void printList(int iActorCount)
{
	cout << "Here is the list of combatants: ";
	for (int index = 0; index < iActorCount; index++)
	{
		aInitOrder[index].printName();
	}
}

	void Actor::printName()
	{
		cout << sActorName;
	}
Last edited on
You need to post the complete error messages, all of them, exactly as they appear in your development environment. Those messages have important information embedded within them to aid in locating and fixing the problems.


Thank you, jlb. I edited the original post with the error messages.
Okay, now you will need to post the code for your classes, especially actor, both the definition and implementations. It would really be a good idea if you posted the smallest possible complete program that illustrates the problem.



Here is Actor.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <string>

namespace actor
{
	class Actor
	{
	public:
		Actor();
		Actor(std::string sActorName, double dInitRoll);
		~Actor();
		void printName();
	private:
		std::string sActorName;
		double dInitRoll;
	};
}

#endif 


And here is Actor.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "Actor.h"
#include <iostream>
#include <string>
using namespace std;
using namespace actor;

namespace actor
{
	Actor::Actor()
	{}

	Actor::~Actor()
	{}

	Actor::Actor(string sActorName, double dInitRoll)
	{}

	void Actor::printName()
	{
		cout << sActorName;
	}
}
And your main.cpp? After all that is where your linker is saying the problem occurs after all.


Here's the Main.cpp:
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
#include "Actor.h"
#include <iostream>
#include <string>
using namespace std;
using namespace actor;

void makeList(int iActorCount);
void printList(int iActorCount);

int iActorCount = 0;
Actor aInitOrder[];

int main()
{
	cout << "Enter the number of combatants: ";
	cin >> iActorCount;

	makeList(iActorCount);
	printList(iActorCount);

	system("PAUSE");
	return 0;
}

void makeList(int iActorCount)
{
	string sName;
	double dRoll;

	cout << "Enter the name and roll of the combatabt: ";
	for (int index = 0; index < iActorCount; index++)
	{
		getline(cin, sName);
		cin >> dRoll;
		aInitOrder[index] = Actor(sName, dRoll);
	}
}

void printList(int iActorCount)
{
	cout << "Here is the list of combatants: ";
	for (int index = 0; index < iActorCount; index++)
	{
		aInitOrder[index].printName();
	}
}
Hi,

The size of an ordinary array must be known at compile time, which is not the case with your code. Consider using a std::vector instead.
TheIdeasMan, thank you for the recommendation. It got rid of the "unknown external symbol" error, but gave me this error instead.
1
2
3
4
5
6
7
8
public:
	_Ty& operator[](const size_type _Pos)
		{	// subscript mutable sequence
 #if _ITERATOR_DEBUG_LEVEL == 2
		if (size() <= _Pos)
			{	// report error
			_DEBUG_ERROR("vector subscript out of range");
			}


I think that one came from the vector library, and it came up in "void makeList()" after I input the double value. I can't tell if it is because of the Actor constructor, the loop cycle, or some other issue.
Hi, can you show your new code?

Edit:

Look in the tutorial top Left of the web page, read up about how to do vectors, look at the examples :+)
Last edited on
Topic archived. No new replies allowed.