Incrementing and decrementing are such common operations that C++ provides special operators for them. The ++ operator adds one to the current value of an int, char or double, and β subtracts one. Neither operator works on strings, and neither should be used on bools.
Looking at this, it is not clear whether the increment will take effect before or after the value is displayed. Because expressions like this tend to be confusing, I would discourage you from using them. In fact, to discourage you even more, Iβm not going to tell you what the result is. If you really want to know, you can try it.
If youβre curious about this, feel free to search up about prefix and postfix increment operators. But for now, just avoid incrementing a variable and using it in an expression at the same time.
Unfortunately, this is syntactically legal, so the compiler will not warn you. The effect of this statement is to leave the value of index unchanged. This is often a difficult bug to track down.