next up previous contents index
Next: Dynamically sized arrays. Up: A note on C++ Previous: On C++ for non-C++   Contents   Index

Subsections

Mathematical operators.

Exponentiation.

The usual operators ($+,-,*,/$) are what you expect, but exponentiation is not a part of the language, these and other mathematical operators are implemented as functions in the math library

Increment and decrement.

When we want to increase the value of one item by one, in most languages this is written:


int i=0
i = i+1
i = i-1

In C++ this operation has its own shorthand


int i=0 
i++
i--

While this does not seem intuitive, and it is excusable to think that this operation is not really necessary, it does come in handy for more abstract data constructs. For example, if one defines a date class with the necessary operations, to get the next date will simply be a matter of

date d(1,1,1995)
d++

These two statements will result in the date in d being 2jan95.


next up previous contents index
Next: Dynamically sized arrays. Up: A note on C++ Previous: On C++ for non-C++   Contents   Index
Bernt Arne Odegaard
1999-09-09