Jump to content
  • Advertisement
Sign in to follow this  
dcuk

inheritance problem??

This topic is 4827 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

explained better slightly further down, with extracts. it compiles fine, just i recieve an error message [Edited by - dcuk on September 23, 2005 5:10:26 AM]

Share this post


Link to post
Share on other sites
Advertisement
"Unresolved external" means that you're trying to use a function that doesn't exist. Do you have all the named functions created? Are they in your project? Do the function signatures match their prototypes exactly?

Share this post


Link to post
Share on other sites
that completely fixed it thanks!

..however it now links fine but 'encountered a problem dialog comes up'

the code that determines it is: (the mArmour and mWeapon)
these are Item objects with weapon and armour inherited, the two items are put into the player private members, so unsure..looks fine?!?



Player::Player()
{
mName = "Default";
mClassName = "Default";
mAccuracy = 0;
mHitPoints = 0;
mMaxHitPoints = 0;
mExpPoints = 0;
mNextLevelExp = 0;
mLevel = 0;
mArmour->SetName("Default");
mArmour->SetValue(0);
//mArmor.mDamageRange = 0;
mWeapon->SetName("Default Weapon Name");
mWeapon->SetValue(230);
mGold = 0;
mRace = "Default";
}

Share this post


Link to post
Share on other sites
lil extracts from other headers with those classes
Item is base of weapon and item


class Item {
public:
Item() {}
virtual ~Item() {}
virtual string GetName() = 0;
virtual void SetName(string name) = 0;
virtual void SetValue(int name) = 0;
virtual int GetValue() = 0;
};


Armour class

class Armour :public Item
{
public:
Armour();
Armour(string Name, int Value) { aName = Name; aValue = Value; }
virtual ~Armour();
virtual string GetName();
virtual int GetValue();
//Range GetRange();

private:
string aName;
int aValue;
//int mDamageRange;
};


Weapon class:

class Weapon :public Item
{
public:
Weapon();
Weapon(string Name, int Value) { wName = Name; wValue = Value; }
virtual ~Weapon() {}
virtual string GetName();
virtual void SetName(string name) { wName = name; }
virtual void SetValue(int name) { wValue = name; }
virtual int GetValue();
//Range GetRange();

private:
string wName;
int wValue;
//Range mDamageRange;
};

Share this post


Link to post
Share on other sites
Looks like you're trying to use garbage pointers:

class Player {
Armour * mArmour;
Weapon * mWeapon;

public:
Player() {
// mArmour->SetName( "mArmour doesn't point to anything yet," );
// mWeapon->SetName( "and neither does mWeapon." );
mArmour = new Armour( "Default Armour", 0 ); // don't forget to delete these
mWeapon = new Weapon( "Default Weapon", 230 ); // in your destructor
}
};

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!