Special attention in the
pre/post
increment/decrement operators
-
Pre-operators
performs the
operation
first (= pre) and
will return the
new value of the
variable
-
Post-operators
performs the
operation
later (= postpone)
and
returns the
old value of the
variable
Examples:
x = 4;
y = ++x; <===> x = x + 1; y = x; (PRE increment)
Result: x = 5 y = 5
x = 4;
y = x++; <===> y = x; x = x + 1; (POST increment)
Result: x = 5 y = 4
|
|