第七周项目4:用多文件组织多个类的程序(1)

问题及代码:

#ifndef WEA_H_INCLUDED
#define WEA_H_INCLUDED
#include"wea.h"
#include<string.h>
#include<iostream>
using namespace std;
class weapon
{
public:
    weapon(string nam,int f);
    int showweapon();
    void show();
private:
    int force;
    string wname;
};
class role
{
public:
    role(string ch,int x,string nam,int f);
    void show();
    int attack(role &r);
    int eat(int n);
    int beattack();
    bool islived();
private:
    string name;
    int blood;
    bool life;
    weapon wea;
};

#endif // WEA_H_INCLUDED

运行结果:


知识点总结:


学习心得:

你可能感兴趣的:(第七周项目4:用多文件组织多个类的程序(1))