However, I'm confused with the usage of the increasing and decreasing operator here. Especially when it comes to the printing of the winner. (Line 53) --player
I do know from the documentation that having the operator as a prefix means that the value of player would be decreased before an assignment to another variable, and if it's used as a suffix it means that it's being copied to another variable before decreasing.
But in this case I'm not assigning player as a value in any variables, so how would this affect my final results? Because if I used player--, my code would show that player 2 won, when in actual fact player 1 won.
Thanks for any help offered, I really appreciate it!
Well, it strictly has to deal with order of events. In this case, player-- will take the current value of player, display it with cout, and then decrement it. --player will decrement it, then display it with cout.
consider the expression x--;, the value of x is decremented by 1, and the expression evaluates to the value of x before the decrement happened. --x;, decrements x by 1, and the expression evaluates to the new value of x (after decrement).
increment is the same.
it might look confusing, but trust me, after you've used these expressions four-five times you'll get used to it, it's really simple.