previous | start | next

## Exception Handling

- This automatic invocation of destructors only applies to objects.
- Consider the following code.

  >     Product* p = new Product();
  >     if (p->read())
  >     {
  >        ...
  >     }
  >     delete p; // never executes if read throws an exception

- If an exception occurs in the `read` function, `p` receives no special attention because it is not an object.
- A memory leak occurs.

previous | start | next