Original Post
Here's my code so far with the problems:
class player
{
public:
player(string, int, int, int, int, int);
~player(void);
void show_player_stats(void);
private:
string player_name;
int weapon_status;
int health;
int armor;
int money;
int experience;
};
void main(void)
{
string name;
cout << "Enter player name:";
cin >> name;
player p1(name, 0, 100, 0, 500, 0);
// this next line causes error 1
player::show_player_stats();
}
player::player(string p_name,int w,int h, int a, int m, int e)
{
this->player_name = p_name;
this->weapon_status = w;
etc etc etc
}
void player::show_player_stats(void)
{
// this line causes error 2
cout << p1.player_name << p1.weapon_status << etc. etc. etc.
}
ERRORS:
Error 2: Undefined symbol 'p1'.
Error 1: Use . or -> to call 'player::show_player_stats()'.
Why the heck am I getting this error?! Of course it's not undefined! I freaking MADE it with "player p1(params)"! (Actually...I don't know if anything I did is right, I'm just yelling cause I'm frustrated and "think" it should work.) I tried declaring p1 globally by doing:
player p1;
at the very top, but then I get the error:
Size of 'p1' is unknown or zero.
Please help. Thanks
PS: How can I get the name the user enters for "name" and get spaces as well? Because with "cin" it doesn't take spaces.
Edited by - Joker2000 on 7/5/00 7:20:15 PM