#include <iostream>
using namespace std;
int blood=10000;
class hero
{
protected:
string name;
int hp;
int attck;
public:
//无参构造
hero():attck(500){}
//有参构造
hero(string name,int hp,int attck):name(name),hp(hp),attck(attck){}
//虚成员函数
virtual void Atk()
{
blood-=0;
}
};
class fas:public hero
{
private:
int ap_atk=50;
public:
void Atk()
{
blood-=(attck+ap_atk);
cout<<blood<<endl;
}
};
class shes:public hero
{
private:
int ac_atk=100;
public:
void Atk()
{
blood-=(attck+ac_atk);
cout<<blood<<endl;
}
};
int main()
{
fas f1;
hero *p=&f1;
p->Atk();
shes s1;
hero *q=&s1;
q->Atk();
int count=0;
while(blood>0)
{
p->Atk();
q->Atk();
count++;
}
cout<<count<<endl;
return 0;
}
c++day5 - 幕布