Modifing Class Data through a Class Function
Hello,
What I am trying to do is edit the variable of a class through a separate class function. I have tried to do things like
int player::attack(int *enemy)
{
srand(time(NULL));
int randomNumber = rand() % 100;
*consolePlayer.health = *consolePlayer.health - randomNumber;
}
and I get the error of :
`consolePlayer' undeclared (first use this function)
I know the anser is probably something I've accidentally overlooked, but could you please help?
Thank You,
EpicAsian
epicasian
Junior Poster in Training
53 posts since Nov 2009
Reputation Points: 12
Solved Threads: 0
Nevermind, I found an alternative that uses pointers.
epicasian
Junior Poster in Training
53 posts since Nov 2009
Reputation Points: 12
Solved Threads: 0