10. What are the compound assignment operators, and how are they useful?
The compound assignment operators consist of an operation followed by an equals sign, and they are shorthand. For example,
x += 1;
is the same as
x = x+1;
They are useful because they can enhance readability, for a dumb compiler may result in more optimized output, and prevent an operand being evaluated more than once in cases such as :
* (get_int_pointer()) += 5;
No comments:
Post a Comment