Im spending my saturday night not dressed up for halloween but rather sitting trying to learn CPP :D
anyways could someone please help me, Below I have included my source code, basically when I try compiling this form the terminal I'm getting a lot of errors, basically stating that the variables "name, ho, etc" are not declared, yet I have included my header file, so could someone pleas shave a look at this and maybe tell me what is missing? Thank you so much in advance guys!
#ifndef __TPLAYER__
#define __TPLAYER__ //prevent multiple #includes
TPlayer
{
private:
char name;
int hp;
int dmg;
int wep;
public:
TPlayer(void);
~TPlayer(void);
//Naming
void SetName(char *_name);
char GetName(void);
//Health
void SetHealth(int *_hp);
int GetHealth(void);
//Damage
int SetDamage(int *_dmp)
//Weapon
void SetWeapon(int *_wep);
int GetWeapon(void);
};
#endif /* TPlayer.h */
and here is my source file:
#include "TPlayer.h"
/////////////////
// Constructor
/////////////////
TPlayer::TPlayer(void)
{
name = "";
hp = 0;
dmg = 0;
wep = 0;
}
///////////////////
// Destructor
///////////////////
~TPlayer::TPlayer()
{
delete name;
delete hp;
delete dmg;
delete wep;
}
///////////////////
// Naming
///////////////////
void SetName(char *_name)
{
name = _name;
}
char GetName(void)
{
return *name;
}
And so forth, yet its telling me that for example, name etc has not been as shown below:
TPlayer.h:4: error: function definition does not declare parameters
TPlayer.cpp:6: error: ‘TPlayer’ has not been declared
TPlayer.cpp:6: error: ISO C++ forbids declaration of ‘TPlayer’ with no type
TPlayer.cpp: In function ‘int TPlayer()’:
TPlayer.cpp:8: error: ‘name’ was not declared in this scope
TPlayer.cpp:9: error: ‘hp’ was not declared in this scope
TPlayer.cpp:10: error: ‘dmg’ was not declared in this scope
TPlayer.cpp:11: error: ‘wep’ was not declared in this scope
TPlayer.cpp: At global scope:
TPlayer.cpp:16: error: expected class-name before ‘::’ token
TPlayer.cpp: In function ‘void SetName(char*)’:
TPlayer.cpp:30: error: ‘name’ was not declared in this scope
TPlayer.cpp: In function ‘char GetName()’: