Annoying Error

So I keep getting a million unresolved external symbol errors when I try to compile my program, I'll post all my code and the errors.

tower.h:
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
#ifndef TOWER_H
#define TOWER_H

#include <string>
#include "player.h"

class tower {
public:
	static int towerid;
protected:
	bool isPlaced(int towerid);
	virtual void upgrade(player& cplayer);
	virtual void sell(int towerid,player& cplayer);
	virtual void sprite(int x, int y);
	virtual void buy(player& cplayer);
	virtual void selecttower(bool towerselected);
	virtual bool gettowerselected();
	int cost;
	int damage;
	int upgradecost;
	double speed;
	int upgrades;
	int upgradepath;
	bool towerselected;
};

#endif 


arrowtower.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef ARROWTOWER_H
#define ARROWTOWER_H

#include "tower.h"
#include "player.h"
#include "darkGDK.h"

class arrowtower : public tower {
public:
	arrowtower();
	void upgrade(player &cplayer);
	void sell(int towerid,player& cplayer);
	void sprite(int x,int y);
	void buy(player& cplayer);
	void selecttower(bool towerselected);
	bool gettowerselected();
};

#endif 


player.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef PLAYER_H
#define PLAYER_H

class player {
public:
	player();
	int getGold();
	void addGold(int amount);
private:
	int gold;
};

#endif 


arrowtower.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
47
48
49
50
51
52
53
54
55
56
#include "arrowtower.h"

arrowtower::arrowtower(){
	cost = 100;
	damage = 4;
	upgradecost = 250;
	speed = 1.0;
	upgrades = 0;
	towerselected = false;
	dbLoadImage("arrowtower.png",1);
}
void arrowtower::upgrade(player &cplayer){
	if (cplayer.getGold() >= upgradecost && upgrades == 0){
		damage = 8;
		upgradecost = 500;
		upgrades++;
	}
	else if (cplayer.getGold() >= upgradecost && upgrades == 1 && upgradepath == 1){
		damage = 15;
		speed = 4.0;
	}
	else if (cplayer.getGold() >= upgradecost && upgrades == 1 && upgradepath == 2){
		damage = 10;
		speed = 0.5;
	}
	else {
		return;
	}
}
void arrowtower::sell(int towerid,player& cplayer){
	dbDeleteSprite(towerid);
	cplayer.addGold(cost/2);
}
void arrowtower::sprite(int x,int y){
	dbSprite(tower::towerid,x,y,1);
}
void arrowtower::buy(player& cplayer){
	if (cplayer.getGold() >= cost){
		cplayer.addGold(-cost);
	}
	else {
		return;
	}
}
void arrowtower::selecttower(bool towerselected){
	if (towerselected)
		towerselected = true;
	else if (!towerselected)
		towerselected = false;
	else {
		return;
	}
}
bool arrowtower::gettowerselected(){
	return towerselected;
}


player.cpp:
1
2
3
4
5
6
7
8
9
10
11
#include "player.h"

player::player(){
	gold = 500;
}
int player::getGold(){
	return gold;
}
void player::addGold(int amount){
	gold += amount;
}


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
#include "darkGDK.h"
#include "player.h"
#include "arrowtower.h"

void DarkGDK(void){
	
	int sprites = 0;
	arrowtower mainarrow;
	player player1;
	dbSyncOn();
	dbSyncRate(60);
	dbDisableEscapeKey();
	dbLoadImage("graphics/background.png",1);
	dbSprite(1,0,0,1);
	dbDrawSpritesFirst();

	while (LoopGDK()){
		if (dbMouseX() > 153 && dbMouseX() < 227 && dbMouseY() > 14 && dbMouseY() < 93){
			if (dbMouseClick() == 1){
				mainarrow.buy(player1);
				mainarrow.sprite(dbMouseX() + 37, dbMouseY() + 37);
				mainarrow.selecttower(true);
			}
		}
		if (mainarrow.gettowerselected()){
			mainarrow.sprite(dbMouseX() + 37, dbMouseY() + 37);
		}
		if (dbEscapeKey() == 1){
			break;
		}
		dbSync();
	}

	for (int i = 0; i < sprites; i++){
		dbDeleteImage(i);
		dbDeleteSprite(i);
	}

	return;
}


errors:
1
2
3
4
5
6
7
8
9
1>LINK : H:\Documents and Settings\Rensel\Desktop\C++ Projects\DeathToGoblins\Debug\DeathToGoblins.exe not found or not built by the last incremental link; performing full link
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>arrowtower.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall tower::upgrade(class player &)" (?upgrade@tower@@MAEXAAVplayer@@@Z)
1>arrowtower.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall tower::sell(int,class player &)" (?sell@tower@@MAEXHAAVplayer@@@Z)
1>arrowtower.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall tower::sprite(int,int)" (?sprite@tower@@MAEXHH@Z)
1>arrowtower.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall tower::buy(class player &)" (?buy@tower@@MAEXAAVplayer@@@Z)
1>arrowtower.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall tower::selecttower(bool)" (?selecttower@tower@@MAEX_N@Z)
1>arrowtower.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall tower::gettowerselected(void)" (?gettowerselected@tower@@MAE_NXZ)
1>arrowtower.obj : error LNK2001: unresolved external symbol "public: static int tower::towerid" (?towerid@tower@@2HA)
You have not implemented the functions in tower.
Maybe you should define your class tower as abstract. In this case its virtual functions can be declared as pure virtual the following way (for example)

bool isPlaced(int towerid) = 0;
Last edited on
Topic archived. No new replies allowed.