ILE C/C++ Programmer's Guide

Defining a C++ _DecimalT Class Template Exception Handler

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.

Figure 309. Example of Using the C++ Try Catch Throw Feature 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;
      }
}


[ Top of Page | Previous Page | Next Page | Table of Contents ]