An object instantiated from an error class is thrown if an error occurred during run time. You can catch the exception by defining your own exception handler.
The following figure illustrates how to use try-catch-throw to handle a _DecimalT class template exception.
#include <bcd.h> #include <iostream.h> void main() { try { _DecimalT<10,2> = __D("AAA"); } catch (_DecErrInvalidConst; Err) { cout <<"Invalid Decimal constant!"<<endl; } } |
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.