A C++ newbie here. As a beginner, I like to play around with different syntax of the language and sometimes I'm faced with situations, such as the one below, that I can't get a hang of.
In the first code below, I observed that the expression "myarray[i]+1" inside the for-loop doesn't change the elements of the array.
Each element are truely incremented by one. What makes the increment/decrement operator so different from the ordinary addition/substraction of one to/from the variable.
The increment operator is actually "add 1 and assign it to the original variable". Whereas the + operator just adds 1.
Examples:
1 2 3 4 5 6 7
int foo = 5 + 3; // foo = 8. This does not change '5'
int bar = foo + 2; // bar = 10. This does not change 'foo', which is still 8
bar++; // this increments bar, so it is now 11
bar += 5; // this adds 5 and assigns it to bar, so it is now 16
// same as "bar = bar + 5;"