TITLE: unexpected and exceptions PROBLEM: johns@crocker.com I am in the process of teaching myself c++ and am currently studying exception handling. I'm using Borland c++ 4.52. What I'm interested in knowing is how to use the unexpected/terminate functions. (along with set_unexpected/terminate) If someone could provide an example (borland help wasn't very clear...), I would greatly appreciate it! RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 14 Jan 96 It is unlikely you will ever need to use the capability. Function "unexpected" is called when a function has an exception specification and it throws a disallowed exception. The default action of the unexpected handler is to call the terminate handler. The default terminate handler just calls abort. Example: void foo() throw( exception ) { ... if( somecondition ) throw 13; // pretty unlucky ... } Function foo promises it will throw only exceptions derived from base class "exception". In fact, it might throw the int value 13. If that happens, the stack is not unwound looking for an int handler, but instead the unexpected handler is called. That will by default call the terminate handler, which will by default abort the program. You can supply your unexpected handler to do something other than just call terminate, and/or your own terminate handler to do something other than just call abort. There are restrictions on what these handlers are allowed to do which I won't go into here.