class Tester
{
int health = 100;
public:
int damage();
int access();
private:
int value(int x);
};
int Tester::damage()
{
health;
health - 20;
return health;
}
int Tester::value(int x)
{
Tester::health = x;
return health;
}
int Tester::access()
{
return value(health);
}
int main()
{
Tester Play;
cout << "Your health is currently: " << Play.access() << endl;
cout << "You take 20 damage\n";
Play.damage();
cout << "Your health is now " << Play.access();
}
Everything works fine but one thing. When the health displays, it says 100. When it displays the second time, its till 100, but should be 80. Please help me with anything i did wrong.