Catching Exceptions with new
void out_of_mem();             //user new handler callback
int main() {
  set_new_handler(out_of_mem); //install user new handler
  while(true)
    int *p = new int[1024];    //gobble up memory till gone
  return (0);
}
void out_of_mem() {
  cout <<"programmer supplied new handler called" <<endl;
  //free up space & return, throw bad_alloc, abort, or exit
  exit(1);
}