#include <iostream>
using namespace std;
class Role
{
public:
Role(string Name,int Blood)
{
name=Name;
blood=Blood;
}
void show()
{
cout<<name<<"剩余"<<blood<<"滴血,";
if(blood>0)
cout<<"it is alived"<<endl;
else
cout<<"it is dead"<<endl;
}
~Role()
{
cout<<name<<"退出江湖..."<<endl;
}
private:
string name;
int blood;
bool life;
};
int main()
{
Role mary("Mary",4);
Role jack("Jack",0);
mary.show();
jack.show();
return 0;
}
角色类游戏,析构函数
最新推荐文章于 2024-09-30 19:45:57 发布