In your case your elf class is not needed. You would be better with adding "race" string member to your class.
Also your mage class wouldn't be able to be used as baseclass reference/pointer as it contain functions you would be like to access by your player.
Better way is to have your character to store types of attacks in them:
1 2 3 4 5 6 7 8 9
|
/*Some enums here*/
[code]struct AttackInfo
{
std::string name;
attack_type type;
attack_element element
int damage;
}
|
//Prototypes
//Assuming character class has .add_attack() function
Character* mage = new Character();
mage.add_attack({"Spell: fireball", ATT_RANGED, ELM_FIRE, 20});
mage.add_attack({"Hit with a staff", ATT_MELEE, ELM_PHYSICAL, 5});
Character* elf = new Character();
elf.add_attack({"Shoot an arrow", ATT_RANGED, ELM_PHYSICAL, 15});
//...
//Somewhere:
Character* player;
switch(selection)
{
case 1:
player = new Character(*mage);
break;
case 2:
player = new Character(*elf);
break;
//...[/code]