unresolved external symbol problems

I am trying to access the SetUp object that I made from another class, but I am getting these errors :

1>SetUp.obj : error LNK2019: unresolved external symbol "private: class SetUp __thiscall SetUp::_setUp(void)" (?_setUp@SetUp@@AAE?AV1@XZ) referenced in function "public: void __thiscall SetUp::setSetUp(class SetUp)" (?setSetUp@SetUp@@QAEXV1@@Z)

1>SetUp.obj : error LNK2019: unresolved external symbol "class Battle __cdecl battle(class SetUp)" (?battle@@YA?AVBattle@@VSetUp@@@Z) referenced in function "public: void __thiscall SetUp::SetUpBattle(void)" (?SetUpBattle@SetUp@@QAEXXZ)

Here is some of my 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
SetUp.cpp
#include "SetUp.h"
#include "Battle.h"

Pokemans pokeman;

Player player1("Player1");
Player player2("Player2");
Battle battle(SetUp setUp);

SetUp::SetUp(){
	
	_player1 = player1;
	_player2 = player2;
	cout << player1.getName() <<" Choose Ur Pokeman \n\n" ;
	SetUpPokemans();
	SetUpPlayer(player1);
	cout << player2.getName() <<" Choose Ur Pokeman \n\n" ;
	SetUpPlayer(player2);

	system("PAUSE");

	SetUpBattle();
	return;
}

void SetUp::SetUpPokemans(){
	Moves move;
	int b = 1;
	vector <Moves> movesM;
	for(b ; b <= 4; b++){
	movesM.push_back(move.movesList(b));
	}
	vector <Moves> movesP;
	for(b ; b <= 8; b++){
	movesP.push_back(move.movesList(b));
	
	}
	vector <Moves> movesH;
	for(b ; b <= 12; b++){
	movesH.push_back(move.movesList(b));	
	}

	
	pokeman.setPokemans("Munchkip", 50, 50, 0, movesM);
	pokeman.setPokemans("Pedulu", 50, 50, 1, movesP);
	pokeman.setPokemans("Habska", 50, 50, 2, movesH);
	vector <Pokemans> _pokemans  = pokeman.getPokemans();
	
	Pokemans poke;

	for( unsigned int a = 0; a < _pokemans.size(); a ++ )
   {
	   cout << a + 1 <<" _ _ _ _ _ _    "<<_pokemans[a].getName() << ":   "<<poke.getMoveName(_pokemans[a], 1) <<", "<<poke.getMoveName(_pokemans[a], 2)<< ", "<<poke.getMoveName(_pokemans[a], 3)<< ", "<<poke.getMoveName(_pokemans[a], 4)<<  endl;
	
	   
   }
		
	return;

}

void SetUp::SetUpPlayer(Player player){
	int input = 0;
	
	
	cin >> input;
	
	vector <Pokemans> pokemans  = pokeman.getPokemans();
	
	switch (input){
		
		case 1:
			player.setPokeman(pokemans[input - 1]);
			break;
		case 2:
			player.setPokeman(pokemans[input - 1]);
			break;
		case 3:
			player.setPokeman(pokemans[input - 1]);
			break;

	}
	
	cout << player.getName() <<" Chose : " << player.getPokemanName() << endl << endl << endl;

	if(player.getName() == "Player1"){
		_player1.setPokeman(player.getPokeman());
		
	}else{
		_player2.setPokeman(player.getPokeman());
	
	}
	return;
}


void SetUp::clearScreen(){
  system("cls");
  return;
}

SetUp::SetUp(int rand){
	cout << "hi";

}

Player SetUp::getPlayer(int num){
	switch (num){
	case 1:
		return _player1;
		break;
	case 2:
		return _player2;
		break;
	default:
		break;
	}
	Player player("ERROR");
	return player;
}


void SetUp::setSetUp(SetUp set_Up){
	_setUp() = set_Up;
	return;
}

SetUp SetUp::getSetUp(){
	return _setUp();
}
void SetUp::SetUpBattle(){
	SetUp setUp(3);
	setUp = _setUp();
	battle(setUp);
	
}

SetUp.h

#pragma once
#include <string>
#include <iostream>
#include "Pokemans.h"
#include "Player.h"



using namespace std;

class SetUp
{
public:
	SetUp();
	SetUp(int rand);
	void SetUpPokemans();
	void SetUpBattle();
	void SetUpPlayer(Player player);
	void clearScreen();
	Player getPlayer(int num);
	void setSetUp(SetUp setUp);
	SetUp getSetUp();

private:
	Player _player1;
	Player _player2;
	SetUp _setUp();
};


Battle.cpp
#include "Battle.h"


Battle::Battle(SetUp set_Up(int i)){

	
	set_Up(3).clearScreen();
	cout << "\n**********LET THE BATTLE BEGIN************\n\n\n";
	system("PAUSE");
	printBattle();
	Player p1 = set_Up(3).getPlayer(1);
	Player p2 = set_Up(3).getPlayer(2);

	cout << p1.getName() << " with "<<p1.getPokemanName() << endl << endl << endl << endl << endl << endl<< endl<< endl<< endl<< endl<< endl<< endl<< endl<< endl << p2.getName() << " with "<<p2.getPokemanName();
	return;
}

void Battle::printBattle(){
	SetUp setUp(3);
	setUp.clearScreen();
	return;

}



Battle.h
#pragma once
#include "SetUp.h"

class Battle
{
public:
	Battle(SetUp setUp(int i));
	void printBattle();

private:
	SetUp _setUp(int i);
};



I have been trying to fix this for ALONG time and I dont know what to do.
Everything was working before I implemented the Battle Class, so dont worry about that
Last edited on
SetUp _setUp(); You've declared this function private. Its a function, not an object. That is your problem. If you want an object, remove the ().

void SetUp::SetUpPlayer(Player player)

When your function takes a class object, you gotta do it by reference. So

void SetUp::SetUpPlayer(Player& player) // add &

Do that everywhere that you take a class obejct.

Edit: And to add to what I said first.

1
2
3
4
 SetUp::setSetUp(SetUp set_Up){
	_setUp() = set_Up;
	return;
}


You cant do that. _setUp is a function, you cant assign a object to a function, that makes no sense if you think about it.
Last edited on
I did that but now I am getting an error in my main.cpp file at l.20(setUp.setSetUp(setUp(3));)



Error 1 error C2064: term does not evaluate to a function taking 1 arguments

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

#include <iostream>
#include <string>

#include "SetUp.h"

using namespace std;

int main () {
	
	
	bool isDone = false;
	
	

	

	cout << "**********Welcome To Pokeman Battles***************"<< endl << endl<<endl<<endl;
	
	SetUp setUp;
	setUp.setSetUp(setUp(3));
	
	

	while(isDone == false){
		
		
		
	}

	system("PAUSE");
	return 0;
}


Still thanks for helping me :D, but I would be grateful if you could explain a bit about the refence thing (I am still very new to c++).
Last edited on
Topic archived. No new replies allowed.