19.3.3 (cont.) Exceptions and Cleaning Up

  1. Make sure all stack values are instances of a class, or
  2. Catch the error, clean up, and rethrow the error:
    Product* p = NULL;
    try
    {
       p = new Product();
       if (p->read())
       { . . . }
       delete p;
    }
    catch (...)
    {
       delete p;
       throw;
    }

prev |top |next