Original Post
I'm trying to pass a cArmor object in a cPlayer object at the constructor... cPlayer header: This is my cPlayer constructor, I get the error here: cArmor.ccp: ERROR: cPlayer.cpp: In constructor
class cPlayer
{
public:
cPlayer (string, cArmor);
// ~cPlayer();
int getHealth() const;
int getMoney() const;
int getEnergy() const;
string getName() const;
void setHealth(int);
void addHealth(int);
void setMoney(int);
void takeMoney(int);
void showStats();
void addEnergy(int);
private:
int signed itsHealth, itsEnergy, itsMaxHealth, itsMaxEnergy;
int itsMoney;
string itsName;
cArmor itsArmor; //
};
cPlayer::cPlayer(string name, cArmor armor)
{
itsMaxHealth=100;
itsMaxEnergy=100;
itsHealth=100;
itsMoney=5000;
itsName=name;
itsEnergy=100;
itsArmor=armor; //i want to set this to a cArmor object
}
//cArmor.cpp
#include "Library.h"
cArmor::cArmor(int value, int ar, int maxdurability)
{
itsValue=value;
itsAR=ar;
itsMaxDurability=maxdurability;
itsDurability=maxdurability;
}
int cArmor::getAR()
{
return itsAR;
}
int cArmor::getValue()
{
return itsValue;
}
int cArmor::getDur()
{
return itsDurability;
}
void cArmor::takeDamage(int amount)
{
itsDurability-=amount;
}
cPlayer::cPlayer(std::string, cArmor)': cPlayer.cpp:8: error: no matching function for call to cArmor::cArmor()' cArmor.h:4: note: candidates are: cArmor::cArmor(const cArmor&) cArmor.h:8: note: cArmor::cArmor(int, int, int)