|
|
|||
![]() |
Department of Engineering |
| University of Cambridge > Engineering Department > computing help |
| integer ops | +, -, *, /, % (modulus) |
e.g. (13+4)/5 is 3 |
| real ops | +, -, *, / |
e.g. (13.0+4.0)/5.0 is 3.4 |
| relational ops | ==, !=, >=, <=, >, < |
e.g. (6+2)<9 is true |
| logical ops | && (and), || (or), ! (not) |
e.g. (6>8) || (3<4) is true |
| bit-shift ops | >>, << |
e.g. 2<<10 is 2048 |
Precedence order:
!, not (logical not)
*, /, %
+, -
>>, <<
<, <=, >, >=
==, !=
&&, and (logical and)
||, or (logical or)
Increment and decrement operators (see section 8 on assignment statements):
count++ is equivalent to count = count + 1;
count-- is equivalent to count = count - 1;
Operators can be defined for user types. See the use of << and
>> in section 11, and the -- member function in
the example class in section 18.
| | computing help | |