 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
When
an error condition is detected, an exception can be
|
|
|
created
and control transferred to an exception handler by
|
|
executing
a throw expression.
|
|
| • |
A
throw expression consists of the operator throw
|
|
|
optionally
followed by an operand of some type.
|
|
if (i != 42) //detect error condition
|
|
throw
i; //throw an exception
|
|
| • |
This
causes the program to abort whenever an exception
|
|
|
occurs.
The abort occurs because the default in C++ is to
|
|
|
abort
whenever an exception is thrown that is not
|
|
|
explicitly
processed by the program. This is probably
|
|
|
only
useful for the simplest programs.
|
|