- operators -- + , - ,.., < , <= ,.., == , != ,.., && , ||
- indexing -- o[ e ]
- application -- o(...)
- access -- o.m(...)
- dereference -- p->m(...)
- in/decrement -- o++, o--
- conditional -- b?e1:e2
- var = expression
- modifying -- +=. -=, ...
slide: C++ -- expressions (2)
Value expressions may be created using
arithmetic and comparison operators
(including == for equality and !=
As logical operators, C++ includes
and disjunction (),
as well as a number of bitwise logical operators.
Also, we have an indexing operator
(which may be defined for arbitrary types),
an application operator
(which may also be defined for arbitrary types),
an access operator
(which is as a standard used for member function
invocation or method calls),
a dereference operator
(which is used to invoke member functions through a
pointer to an object)
and in- and decrement
(that, again, may be defined for arbitrary types).
Needless to say, user-defined operators
must be applied with care.
Also, we have a conditional expression of the form
b?: testing the condition b to
deliver when it evaluates to true and otherwise.
Also, C++ allows for sequencing within expressions
of the form ,
which evaluates in that order
and delivers as its value.
Assignments in C++, it is important to note,
are written as var = expression with a single =
This convention is known to cause mistakes by programmers
raised with languages such as Pascal or Modula-2.
In addition, C++ offers modifying assignments,
which may be used as, for example, in n += 1,
which is identical in meaning to n = n + 1.