 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
void
user_terminate() { //user
supplied terminate
|
|
cout <<"user terminate
function calling exit" <<endl;
|
exit(1); //abnormal program exit
|
|
}
|
|
|
int
main() {
|
|
int i;
|
|
set_terminate(user_terminate); //install
user function
|
|
cout <<"Enter an integer:
";
|
|
cin >>i;
|
|
|
if (i != 42) //detect error condition
|
|
throw i; //throw an exception
|
|
cout <<"no throw was
executed" <<endl;
|
|
|
cout <<"normal program exit;
i = " <<i <<endl;
|
|
return(0);
|
|
}
|
|