Hi I am making a pretty large text game and I now have to make the player file.
I am torn betwen either this:
Code:
struct Player
{
static string m_nm;
static int m_hp;
};
string m_nm = "";
int m_hp = 100;
which looks like I am attempting to find a way round of not global variables
or this way: ps - this a basic example of what I might do
Code:
class Player
{
public:
Player();
~Player();
protected:
// pointers
string *m_nm;
int *m_hp;
};
Player::Player()
{
m_nm = new string("");
m_hp = new int(100);
}
Player::~Player()
{
delete m_nm;
m_nm = NULL;
delete m_hp;
m_hp = NULL;
}
int main()
{
Player *play = new Player;
delete play;
play = NULL;
return 0;
}
Basicly, I was thinking of doing the second method, all the Player data members
woulds be derived from a base class.
Which method is best to use?