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