 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
void
a_function() throw(char, int) { //exception spec
|
|
int i;
|
|
char c;
|
|
cout <<"Enter a character and
an integer: ";
|
|
cin >>c >>i;
|
|
|
if (c != 'x')
|
|
throw c; //throw char exception
|
|
if (i != 42)
|
|
throw i; //throw int exception
|
|
|
cout <<"no throw was
executed" <<endl;
|
|
}
|
|
| • |
If a
function throws an exception that is not in the
|
|
|
exception
specification list, a call to a run time library
|
|
function
called unexpected is made. The default
|
|
|
behavior
for unexpected is to call terminate.
|
|