CS202 5- ‹#›
Throwing an Exception
nWhen an error condition is detected, an exception can be created and control transferred to an exception handler by executing a throw expression.
nA throw expression consists of the operator throw optionally followed by an operand of some type.
n if (i != 42)  //detect error condition
n  throw i;   //throw an exception
n
nThis 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.