C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 02-20-2009, 08:24 AM   #1
Registered User
 
Join Date: Sep 2008
Posts: 14
What is Visual C++ saying?

Okay, so I am making a text RPG, and for some reason the Player object makes this error:
Quote:
player.obj : error LNK2001: unresolved external symbol "public: void __thiscall PLAYER::SetAmo(int)" (?SetAmo@PLAYER@@QAEXH@Z)
C:\Documents and Settings\Glitch\Desktop\Games\Skets series\Skets in CRYSTAL BOND\Release\Skets in CRYSTAL BOND.exe : fatal error LNK1120: 1 unresolved externals
I don't get it at all, does anyone know if they can help me, Player's code is:
Code:
//Player behavior

class PLAYER
{
	private:
		//System
		int level;
		int gems;	//Gems are money
		int exp;
		//Stats
			int atk;	//Attack
			int def;	//Defence
			int spd;	//Speed
			int hlt;	//Health
			int amo;	//Laser Energy
			//Maxium
			int MaxHlt;		//Maxium Health
			int MaxAmo;		//Maxium Laser Energy

	public:
		void SetName(char* newname);
		void GetName();
		//Gems
			void SetGems(int newgems);
			void AddGems(int value);
			int GetGems();
		//Current Health and Laser Energy
			void SetHlt(int newhlt);	//Health
			void AddHlt(int value);
			int GetHlt();
			void SetAmo(int newAmo);		//Laser Energy
			void AddAmo(int value);
			int GetAmo();
		//Stats
			void SetAtk(int newatk);	//Attack
			int GetAtk();
			void SetDef(int newdef);	//Defence
			int GetDef();
			void SetSpd(int newspd);	//Speed
			int GetSpd();
			void SetExp(int newexp);	//Experience
			void AddExp(int addexp);
			int GetExp();
			void SetMaxHlt(int newMaxHlt);	//Max Health
			int GetMaxHlt();
			void SetMaxAmo(int newMaxAmo);	//Max Laser Energy
			int GetMaxAmo();
};
Thanks in advanced, no need to break the code down, I mainly want to know what error Visual C++ is giving me.
GlitchGuy2 is offline   Reply With Quote
Old 02-20-2009, 08:43 AM   #2
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
You have, probably, not defined the function SetAmo for that class.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 02-20-2009, 08:47 AM   #3
BMJ
Registered User
 
Join Date: Aug 2002
Posts: 1,330
It means that SetAmmo isn't defined anywhere that the linker knows to look.
BMJ is offline   Reply With Quote
Old 02-20-2009, 01:12 PM   #4
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
Translation:
player.obj : error LNK2001: The public class member function SetAmo that takes an int that is located in the class PLAYER was not found. Please implement it.
C:\Documents and Settings\Glitch\Desktop\Games\Skets series\Skets in CRYSTAL BOND\Release\Skets in CRYSTAL BOND.exe : fatal error LNK1120: 1 function could not be found.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 02-20-2009, 03:55 PM   #5
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,929
It means you declared SetAmo(int) but failed to define it.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is offline   Reply With Quote
Old 02-20-2009, 04:42 PM   #6
The larch
 
Join Date: May 2006
Posts: 3,082
One mistake I make quite often that can result is that when the function is defined I forget to mark it as a member function.

Code:
//void SetAmo(int newAmo) {...}

void PLAYER::SetAmo(int newAmo) {...}
As to the general design of the class, well that's how tutorials often teach it. Hide members and provide accessors for everything.

However, it also shows that this class is supposed to be entirely controlled from the outside and the only purpose it serves is hiding the data, hence making external controlling more awkward.

I don't mean that you should make the members public, but might instead consider moving some of the functionality into the class. What you should see as a result are method names that describe actual actions (attack, defend, level_up, buy_ammo etc) rather than name manipulations of particular member variables. (Getters are somewhat more acceptable - you may want to query the class for info -, but abundance of setters indicates that the class might not be doing much useful.)
__________________
I might be wrong.

Quote:
Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Quoted more than 1000 times (I hope).
anon is offline   Reply With Quote
Reply

Tags
c++, error, rpg, text, visual

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
We Got _DEBUG Errors Tonto Windows Programming 5 12-22-2006 05:45 PM
C++ std routines siavoshkc C++ Programming 33 07-28-2006 12:13 AM
load gif into program willc0de4food Windows Programming 14 01-11-2006 10:43 AM
Errors with including winsock 2 lib gamingdl'er C++ Programming 3 12-05-2005 08:13 PM
Learning OpenGL HQSneaker C++ Programming 7 08-06-2004 08:57 AM


All times are GMT -6. The time now is 09:25 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22