< previous page page_510 next page >

Page 510
OperatorRemarks
Combined assignment operators
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
+= Add and assign
-= Subtract and assign
*= Multiply and assign
/= Divide and assign
Increment and decrement operators
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
++ Pre-increment
++ Post-increment
-- Pre-decrement
-- Post-decrement
Example: ++someVar
Example: someVar++
Example: --someVar
Example: someVar--
Bitwise operatorsInteger operands only
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
< Left shift
>> Right shift
& Bitwise AND
| Bitwise ORê Bitwise EXCLUSIVE OR
~ Complement (invert all bits)
More combined assignment operatorsInteger operands only
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
%= Modulus and assign
<= Shift left and assign
>>= Shift right and assign
&= Bitwise AND and assign
|= Bitwise OR and assign
ê= Bitwise EXCLUSIVE OR and assign
Other operators
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
() Cast
sizeof Size of operand in bytes
?: Conditional operator
Form:sizeof Expr or sizeof(Type)
Form:Expr1? Expr2: Expr3

The operators in this table, along with those you are already familiar with, comprise mostbut not allof the C++operators. We introduce a few more operators in later chapters as the need arises.
Assignment Operators and Assignment Expressions
C++ has several assignment operators. The equal sign (=) is the basic assignment operator. When combined with its two operands, it forms an assignment expression (not an assignment statement). Every assignment expression has:

 
< previous page page_510 next page >