做动漫网站要多少钱,免费申请账号网站,午夜做网站,深圳有做网站的公司全局变量#xff0c;int monster 10000:定义英雄类hero#xff0c;受保护的属性string name#xff0c;int hp,int attck;公有的无参构造#xff0c;有参构造#xff0c;虚成员函数 void Ak(blood-0)#xff0c;法师类继承自英雄类#xff0c;私有属性 int p_atk50;重写…全局变量int monster 10000:定义英雄类hero受保护的属性string nameint hp,int attck;公有的无参构造有参构造虚成员函数 void Ak(blood-0)法师类继承自英雄类私有属性 int p_atk50;重写虚成员函数void Ak(blood-(attckp_atk);射手类继承自英雄类私有属性 int c_atk 100;重写成员函数void Ak(blood-(attckc_atk);实例化类对象判断怪物何时被杀死
#include iostreamusing namespace std;
int monster10000;
class hero
{
protected:string name;int hp;int attck100;
public:hero(){}hero(string a,int b,int c):name(a),hp(b),attck(c){}virtual void atk(int blood){ blood - 0;}
};
class fs:public hero
{int ap_atk50;
public:fs(){}fs(string a,int b,int c):hero(a,b,c){}void atk(int blood){blood-(attckap_atk);}
};
class ss:public hero
{int ad_atk100;
public:ss(){}ss(string a,int b,int c):hero(a,b,c){}void atk(int blood){blood-(attckad_atk);}
};
int main()
{fs f(奥特之母,1200,50);ss s(奥特之父,1000,100);int a0;while(monster0){a;coutmonstermonsterendl;f.atk(monster);s.atk(monster);}cout\n怪兽在经历的第a次攻击后被奥特曼打死endl;return 0;
}