Base class:
class Entity {
public:
// friend
// e1 attacker, e2 target
friend void Attack( Entity &e1, Entity &e2 );
// methods set attributes
virtual void setDamage ( int x ) { this -> Damage = x; }
virtual void setHealthPoints ( int x) { this -> HealthPoints = x; }
// methods return attributes
virtual int getDamage ( ) { return Damage ; }
virtual int getHealthPoints ( ) { return HealthPoints; }
protected:
// Attributes
int Damage;
int HealthPoints;
};
Derived class:
class Ninja: public Entity{
public:
// Ninja constructor
Ninja ( int x, int y )
: Damage ( x ), HealthPoints ( y )
};
Edit: Hey, i keep getting "class 'Ninja' does not have any field named 'Damage" on the code mentioned before, also the HealthPoints(sorry, this sentence got removed after posting the question)
i tryied pointing Damage and HealthPoints( * ,this,&) but i'm getting " expected identifier before '*' token. The only way it works is initializing them normally, but what if i want to have const Damage?