// PLAYER CLASS
class PLAYER
{
private:
//DATA MEMBERS FOR PLAYER CLASS
char name[32];
int strength;
int intelligence;
int gold;
int experience;
int health;
int maxhealth;
int Potion;
int maxPotion;
int level;
public:
bool SetName(char *newName);
char* GetName();
void SetStrength(int newstr);
int GetStrength();
void SetIntel(int newint);
int GetIntel();
void SetGold(int newGold);
void AddGold(int amount);
int GetGold();
void SetXp(int newXp);
void AddXp(int amount);
int GetXp();
void SetHealth(int newHealth);
void AddHealth(int value);
void LoseHealth(int value);
int GetHealth();
void SetMaxHealth(int newMaxHealth);
int GetMaxHealth();
void SetPotion(int newPotion);
void AddPotion(int amount);
void LosePotion(int amount);
int GetPotion();
void SetMaxPotion(int newPotion);
int GetMaxPotion();
};
here's the error im getting
Error 1 error C2011: 'PLAYER' : 'class' type redefinition c:\users\x d y n a s 7 y\desktop\afternoon\runesofsarnac\runesofsarnac\player.h 4
1) The console is a terrible medium for games. Save yourself a headache and get a graphical lib designed for making games (like SFML). You actually might be surpised how easy it is.
2) I was never a fan of private vars with dozens of get/set functions. I mean I understand you're trying to be OOP concious, but really this is a little ridiculous, don't you agree? I mean writing all those get/sets is really just a giant waste of time.
thanks man, that worked i do agree a game lib would be better but its a strictly text based thing
im in school and working on a project and we have to learn the basic tedious stuff lol
Getters and setters must be public, the whole point of having them is to keep the data members they refer to private. As far as I know, the only reason to have getters/setters (in other words, the only reason to keep data members private) would be to enforce an invariant, making sure the data always has reasonable state.
I think you're mixing things up a bit here:
only the declarations are in private
The getters and setters have to be declared too, and they're declared to be public.
Nothing wrong with that, just take what your teachers say with a big pinch of salt. If you're interested in doing some study on your own, I recommend Stroustrup's book Programming Principles and Practices Using C++.