Wednesday, 21 August 2013

illegal call of non-static member function

illegal call of non-static member function

I'm having trouble with this function below:
char* GetPlayerNameEx(int playerid)
{
char Name[MAX_PLAYER_NAME], i = 0;
GetPlayerName(playerid, Name, sizeof(Name));
std::string pName (Name);
while(i == 0 || i != pName.npos)
{
if(i != 0) i++;
int Underscore = pName.find("_", i);
Name[Underscore] = ' ';
}
return Name;
}
declaration:
char* GetPlayerNameEx(int playerid);
usage:
sprintf(string, "%s", CPlayer::GetPlayerNameEx(playerid));
Now my problem here is
"c:\users\tom\documents\visual studio 2010\projects\surreal
roleplay\surreal roleplay\surreal roleplay.cpp(31): error C2352:
'CPlayer::GetPlayerNameEx' : illegal call of non-static member function
c:\users\tom\documents\visual studio 2010\projects\surreal
roleplay\surreal roleplay\player.h(5) : see declaration of
'CPlayer::GetPlayerNameEx'"
If this has anything to do whith it which I doubt it does, this function
is contained within a "Class" header (Declartion).
Also I have no idea why but I can't get the "Code" box to fit over correctly.

No comments:

Post a Comment