those are called compound assignment operators. There are almost 10 of them in C/C++ language. ex += -= *= <<= >>=
. When one of the operand is same as the variable to which final result to be assigned is same, in a binary operation this can be used as a short hand syntax. Ex a=a+b
can be written as a+=b
. in the same a=a<<2
can be written as a<<=2
. This type of syntactic sugar is also supported by other languages too.
solved What is the use of >>= or <<= compound assignment in c++?