I'm trying to make a small text-game that revolves around armies. I have a unit class
class Unit
{
protected:
string m_name;
short m_health;
unsigned short m_damage, m_block, m_experience;
public:
Unit()
{
}
};
This was a rough outline - I'd later add methods that I'd want the specific unit classes to inherit - units like Barbarians, Soldiers, etc. Now I want these units, when created, to have their stats assigned based on whichever unit they are. For example,
Barbarian unit_barbarians[100];
I want to be able to write this line and have all the stats already set upon creation, but since it's a derived class of Unit, I'd have to call the unit constructor first and assign them there, and to do so I'd have to pass arguments to the constructor, but I just want to pass them through an initializer list in the Barbarian class...
Should I be assigning all the values in the constructor body or is there a better way? I really hope I'm making sense here.