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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started