dimanche 16 décembre 2018

multilevel constructors in c++

Okay we had the Task to create a constructer for a class which inherits from another, which also inherits from another class. Our solution to this was the following code:

AxeThrowerTroll:: AxeThrowerTroll(std::string name, char team, int health, unsigned int power, unsigned int armor, unsigned int numAxes)
: Troll(Monster(name, team, health, power), armor(armor)), numAxes(numAxes)
{
}

But if we want to compile the code we get the following error:

error: 'armor' cannot be used as a function

Does one of you have a suggestion how we get this to work?

Aucun commentaire:

Enregistrer un commentaire