Compound
Assignment and Comma Operators
Compound Assignment Operators:
Pay particular attention to the sidebar on Assignment Side-Effects!
Examples:
Total = Total + 3;
Can be written as follows:
Total += 3;
Comma Operator:
Expressions can be separated by commas. Each comma separated expression is evaluated and the value returned from the group is the value of the rightmost expression.
int val, amt, tot, cnt;
amt = 10.;
tot = 12;
cnt = 46;
val = (amt++, --tot, cnt+3);
std::cout << val;
Produces the output, 49
[I have never seen this used in practice – the only other significant use of the comma operator is in Multiple Inheritance, page 314]