+ 2
SOLVE Code block cant process protected inheritance
help me.. the error says enemy::attack power is protected https://code.sololearn.com/c1A54u4alJ4H/?ref=app
2 odpowiedzi
+ 2
I assume you fixed it as I don't get an error.
0
Polymorphism
Fill in the blanks to declare Enemy pointers to the ''Ninja'' and ''Monster'' objects. Set the ''attackPower'' of those objects via ''Enemy'' pointers, then call attack() functions of both ''Ninja'' and ''Monster'' objects:
Enemy * e1 = &ninjaObj;
Enemy* e2 = &monsterObj;
e1->setAttackPower(29);
e2->setAttackPower(99);
ninjaObj.attack();
monsterObj.attack();