I have a base class Character, that can Attack(), and derived classes Magician(10), Elf(5) or Giant(15).
Magicians can evolve to BlackMagician(15)
each type of Character has a defined Power(in parenthesis). My question is how to associate a class with a static function getFamilyPower() and overrride it, accordingly.
The code is below: https://codecollab.io/@sdudnic/warriors
The idea is the following:
class Character {
static int power;
public:
static int getPower() { return power; }
virtual int Attack(Character *other) { /*...*/ }
};
class Magician : public Character {
static int power = 10;
public:
static int getPower() {return power; }
};
class Elf : public Character {
static int power = 5;
public:
static int getPower() {return power; }
};
class Giant : public Character {
static int power = 15;
public:
static int getPower() {return power; }
};