Question: C++ fix the code #include stdafx.h #include using namespace std; class Enemy { protected: int attackPower; public: int setAttackPower(int a) { attackPower = a; }

C++ fix the code

#include "stdafx.h" #include using namespace std;

class Enemy { protected: int attackPower; public: int setAttackPower(int a) { attackPower = a; }

};

class Ninja : public Enemy { public: void attack() { cout << " i am a ninja ninja chop! -" << attackPower << endl;}

};

class Monster : public Enemy { public: void attack() { cout << "monster must eat you !!!-" << attackPower << endl; } };

int main() { Ninja n; Monster m; Enemy *enemy1 = &n; Enemy *enemy2 = &m; enemy1->attackPower(22); enemy2->attackPower(99);

n.attackPower(); m.attackPower();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!