First page Back Continue Last page Graphics
fig13_03.cpp
(1 of 2)
1 // Fig. 13.3: fig13_03.cpp
2 // Demonstrating stack unwinding.
3 #include <iostream>
4
5 using std::cout;
6 using std::endl;
7
8 #include <stdexcept>
9
10 using std::runtime_error;
11
12 // function3 throws run-time error
13 void function3() throw ( runtime_error )
14 {
15 throw runtime_error( "runtime_error in function3" ); // fourth
16 }
17
18 // function2 invokes function3
19 void function2() throw ( runtime_error )
20 {
21 function3(); // third
22 }
23