Heres the scenario, I have a class:
And I want to change that class variable (RandomVariable) doing something like this:
But this only changes the variable of Player that has been created in main under the instance of player, how do I make it actually change the class variable so that it then changes it over the entire program, rather than only in that instance.
Sorry for poor wording, only just started C++ so finding it difficult to express what I mean!
Code:
class Player
{
public:
Player();
int RandomVariable;
};
Player::Player()
{
RandomVariable = 10;
}
And I want to change that class variable (RandomVariable) doing something like this:
Code:
int main()
{
Player player;
player.RandomVariable = 5;
}
But this only changes the variable of Player that has been created in main under the instance of player, how do I make it actually change the class variable so that it then changes it over the entire program, rather than only in that instance.
Sorry for poor wording, only just started C++ so finding it difficult to express what I mean!