Feb 18, 2021 at 5:30pm UTC
I was just messing around and reviewing some of the stuff I learned and I noticed that the variable wont update. Any tips on how to fix this?
#include <iostream>
using namespace std;
int main()
{
int LooseMoney = 5;
int Money = 100;
enum Weapons {Sword=23,Knife=5,Staff,Wand=50};
cout << "You have " << Money - Sword << " dollars left\n";
cout << "You found some money on the floor and picked it up congrats you found " << LooseMoney << " dollars\n";
cout << "You now have " << LooseMoney + Money << " dollars\n";
return 0;
}
Feb 18, 2021 at 5:44pm UTC
I wish my wallet behaved like that!
You output the result of expressions ( Money-Sword and LooseMoney+Money). But you never changed any of those variables.
You could do things like
Money = Money - Sword;
or, equivalently,
Money -= Sword;