2 Unresolved external symbol errors

I am getting 2 unresolved external symbol errors (Error 1 error LNK2019: unresolved external symbol "private: class SetUp __thiscall SetUp::_setUp(int)" (?_setUp@SetUp@@AAE?AV1@H@Z) referenced in function "public: class SetUp __thiscall SetUp::getSetUp(void)" (?getSetUp@SetUp@@QAE?AV1@XZ) C:\Users\luis\Desktop\Pedris Khan\Pokeman Battles\Pokeman Battles\SetUp.obj Pokeman Battles and Error 2 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) C:\Users\luis\Desktop\Pedris Khan\Pokeman Battles\Pokeman Battles\SetUp.obj Pokeman Battles)

I dont know what i am doing wrong


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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
  #pragma once
#include "SetUp.h"
#include<iostream>
using namespace std;

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

private:
	
};




#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 setUpi(3);
	setUpi.clearScreen();
	return;

}







#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);
	SetUp getSetUp();
	void setSetUp(SetUp& set_Up(int i));

private:
	Player _player1;
	Player _player2;
	SetUp _setUp(int i);

};





#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){
	int i = 3;
	return;

}

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(int i)){
	_setUp(3) = set_Up(3);
	return;
}

SetUp SetUp::getSetUp(){
	SetUp setUpi(3);
	return _setUp(3);
	return setUpi;
}
void SetUp::SetUpBattle(){

	
	battle(getSetUp());
	
}






#include <iostream>
#include <string>

#include "SetUp.h"

using namespace std;

SetUp setUp(3);

int main () {
	
	
	bool isDone = false;
	
	

	

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

	while(isDone == false){
		
		
		
	}

	system("PAUSE");
	return 0;
}



#pragma once
#include <string>
#include <iostream>
#include "Attributes.h"
#include "Moves.h"
#include <vector>

using namespace std;

class Pokemans
{
public:
	
	Pokemans(string name, int attack, int deffence, int index, vector <Moves> moves);
	Pokemans();
	vector<Pokemans> getPokemans();
	void setPokemans(string name, int attack, int deffence, int index, vector <Moves> moves);
	string getMoveName(Pokemans pokeman, int index);
	vector<Moves> getMoves();
	string getName();
	
private:
	string _name;
	int _attack;
	int _deffence;
	int _index;
	vector <Moves> _moves;
	vector <Pokemans> _pokemans ;
};


#include "Pokemans.h"




Pokemans::Pokemans (string name, int attack, int deffence, int index, vector <Moves> moves) {
	_index = index;
	_name = name;
	_moves = moves;
	_deffence = deffence;
	vector <Moves> _moves = moves;
	_attack = attack;
	
}
Pokemans::Pokemans(){


}

vector<Pokemans> Pokemans::getPokemans (){
	return _pokemans;
}


void Pokemans::setPokemans (string name, int attack, int deffence, int index, vector <Moves> moves){
	
	
	Pokemans pokeman(name, attack, deffence, index, moves);
	
	_pokemans.push_back(pokeman);
	
	

	return ;
}


string Pokemans::getName(){
	return _name;
}

vector<Moves> Pokemans::getMoves (){
	return _moves;

}


string Pokemans::getMoveName(Pokemans pokeman, int index){
	Moves move;
	vector<Moves>poke = pokeman.getMoves();
	return move.getName(poke[index - 1]);
	 
}



#pragma once
#include <string>
#include <iostream>
#include "Pokemans.h"
using namespace std;


class Player
{
public:
	Player(string name);
	Player();
	void setPokeman(Pokemans pokemon);
	Pokemans getPokeman();
	string getPokemanName();
	string getName();

private:
	Pokemans _pokeman;
	string _name;
};





#include "Player.h"


Player::Player(string name)
{
	_name = name;
}

void Player::setPokeman(Pokemans pokeman){
	_pokeman = pokeman;
}

Pokemans Player::getPokeman(){
	return _pokeman;
}

string Player::getPokemanName(){
	return _pokeman.getName();
}

string Player::getName(){
	return _name;
}

Player::Player(){

}
Line 75: You have a function declaration for _setup(), but I see no implementation for it.
The linker is telling you that you can not call a function that you haven't coded.

Lines 213-214: You have two return statements. One of them is not going to get executed.


i removed the second return statement, but I still get the same errors. And I dont find any _setup() (You probably meant _setUp(int i) but I am using that at multiple occasions like on line 207 ).
The second return statement had nothing to do with your undefined externals. just a passing observation.

Yes, I meant _setUp().

I am using that at multiple occasions like on line 207

Did you read what I said?

The linker is telling you that you can not call a function that you haven't coded.

Where have you coded that function?

its not a function its a variable (type SetUp(int rand))
No, it's not. What you have coded is a function declaration.

If you want a variable, then it should look like:
 
	SetUp _setUp;


Note that your use of _setUp at line 207 is bogus. You can't invoke a constructor on the left hand side of an assignment.
Last edited on
I already tried SetUp _setUp; but it says that it is an incomplete type(I am a very big noob, sry)
and what should I do on line 207?
Since I don't understand what you're trying to do with line 75, I can't really answer the question.

Why are you trying to include an instance of Setup inside the Setup class? There are ways around the incomplete type problem, but I'm not sure you're ready for them.
Last edited on
Many thanks. I have been halted from working on my game for quite a while because I didnt know how to fix my error and didnt try to go around it trying to fix it without actually fixing it.
I am really glad that you told me that it was to complex for me
Here is what I did (just cause)
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
SetUp.cpp
#include "SetUp.h"


Pokemans pokeman;
string name1;
string name2;



SetUp::SetUp(){
	
	cout << "What is Player1s Name? \n";
	cin >> name1;
	cout << "What is Player2s Name? \n";
	cin >> name2;
	

	Player player1(name1);
	Player player2(name2);
	_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");

	
	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() == name1){
		_player1.setPokeman(player.getPokeman());
		
	}else if(player.getName() == name2){
		_player2.setPokeman(player.getPokeman());
	
	}
	else{
		cout << "Error";
		system("Pause");
	}
	return;
}


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



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


SetUp.h

#include "Pokemans.h"
#include "Player.h"



using namespace std;

class SetUp
{
public:
	SetUp();
	
	void SetUpPokemans();
	
	void SetUpPlayer(Player& player);
	void clearScreen();
	Player getPlayer(int num);
	

private:
	Player _player1;
	Player _player2;
	

};

main

#include <iostream>
#include <string>

#include "Battle.h"

using namespace std;



int main () {
	
	
	bool isDone = false;
	
	

	cout << "**********Welcome To Pokeman Battles***************" << endl << endl << endl << endl;
	Battle _battle;


	
	
	
	
	 
	

	while(isDone == false){
		
		
	}

	system("PAUSE");
	return 0;
}

Battle.h

#pragma once
#include "SetUp.h"
#include<iostream>
using namespace std;

class Battle
{
public:
	Battle();
	void printBattle();
	

private:
	Player p1;
	Player p2;
};


Battle.cpp
#include "Battle.h"
#include "SetUp.h"



Battle::Battle(){

	
	SetUp _setUp;

	
	
	p1 = _setUp.getPlayer(1);
	p2 = _setUp.getPlayer(2);
	printBattle();


	
	return;
}

void Battle::printBattle(){
	system("cls");
	cout << "\n**********LET THE BATTLE BEGIN************\n\n\n";
	system("PAUSE");
	system("cls");

	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;

}


I pretty much just changed the role of SetUp and Battle, so that Battle calls SetUp and not SetUp call Battle
Topic archived. No new replies allowed.