Here is the class:
class friendly : public unit{public: int strength; int reflex; int speed; int endurance; int smarts; int perception; double carried; int healthPointsMax; //Derived double carryingCapacity;//Derived vector<weapon> vwTable; vector<ammo> vaTable; weapon equippedMain; weapon equippedPistol; weapon equippedGrenade; //Functions friendly(); friendly(string n, int str, int ref, int spd, int end, int smrt, int per);};Here is the constructor code:
friendly::friendly(string n, int str, int ref, int spd, int end, int smrt, int per){ name = n; strength = str; reflex = ref; speed = spd; endurance = end; smarts = smrt; perception = per; healthPoints = end*2+10; healthPointsMax = end*2+10; goPoints = 20+spd+end/2; blitz = spd/2; carryingCapacity = str*5+15; thrownAttack = str+per/2; thrownDefense = ref+smrt/2; meleeAttack = str+smrt/2; meleeDefense = ref+per/2; rangedAttack = smrt+ref/2; rangedDefense = per+str/2; carried = 0; equippedMain = noweapon; //THIS IS equippedPistol = noweapon; //THE equippedGrenade = noweapon; //PROBLEM isFriendly = true;}The problem is that equippedMain and the other equipped variables are not being set to noweapon.
weapon is another class and noweapon is an instance of that class. noweapon has an overloaded equality operator. When I use breakpoints it shows that noweapon has all blanks for all it's members. This is incorrect and it should have "none" for it's name member. I have also tried other weapons and that doesn't work either.
What am I missing?
PS if you need the code for weapon or it's operator= function let me know.
PPS Why do all the '+' signs get erased in the [ source ] tags?
Nevermind, I guess it's only in "Preview" mode.