For instance, here are the functions for player::death and player:isDead as defined in player.cpp:
Code:
// report whether character is dead
bool player::death()
{
return playerdeath;
}
// check whether character is dead
void player::isDead()
{
if(HP<=0) // HP less than 0, character is dead
{
cout<<name<<" is Dead." <<endl;
system("pause");
playerdeath=1; // give the label of death value 1
}
}
Along with the prototypes:
Code:
#ifndef _PLAYER
#define _PLAYER
#include <iomanip> // use for setting field width
#include <time.h> // use for generating random factor
#include "container.h"
enum job {sw, ar, mg}; /* define 3 jobs by enumerate type
sword man, archer, mage */
class player
{
friend void showinfo(player &p1, player &p2);
friend class swordsman;
protected:
int HP, HPmax, MP, MPmax, AP, DP, speed, EXP, LV;
// General properties of all characters
string name; // character name
job role; /* character's job, one of swordman, archer and mage,
as defined by the enumerate type */
container bag; // character's inventory
public:
virtual bool attack(player &p)=0; // normal attack
virtual bool specialatt(player &p)=0; //special attack
virtual void isLevelUp()=0; // level up judgement
void reFill(); // character's HP and MP resume
bool death(); // report whether character is dead
void isDead(); // check whether character is dead
bool useHeal(); // consume heal, irrelevant to job
bool useMW(); // consume magic water, irrelevant to job
void transfer(player &p); // possess opponent's items after victory
void showRole(); // display character's job
private:
bool playerdeath; // whether character is dead, doesn't need to be accessed or inherited
};
#endif
They seem to be correct. Am I missing something here?
EDIT: Error in the includes, should have included the right headers.