First page Back Continue Last page Graphics
fig13_06.cpp
(1 of 2)
1 // Fig. 13.6: fig13_06.cpp
2 // Demonstrating set_new_handler.
3 #include <iostream>
4
5 using std::cout;
6 using std::cerr;
7
8 #include <new> // standard operator new and set_new_handler
9
10 using std::set_new_handler;
11
12 #include <cstdlib> // abort function prototype
13
14 void customNewHandler()
15 {
16 cerr << "customNewHandler was called";
17 abort();
18 }
19
20 // using set_new_handler to handle failed memory allocation
21 int main()
22 {
23 double *ptr[ 50 ];
24