1 / 8

C++ Exception Handling

C++ Exception Handling. C++ Exception Handling. Some Differences. No finally clause throw versus throws No root exception class Few C++ library routines throw exceptions. No finally clause. But all destructors will be invoked. See auto_ptr info. t hrow (C++) versus throws.

aradia
Download Presentation

C++ Exception Handling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C++ Exception Handling

  2. C++ Exception Handling

  3. Some Differences • No finally clause • throw versus throws • No root exception class • Few C++ library routines throw exceptions

  4. No finallyclause • But all destructors will be invoked. • See auto_ptr info

  5. throw (C++) versus throws • No compile time checks of throw list • Missing throw list is allowed • Backward compatibility

  6. No root exception class • Java Throwable objects contain a stack trace, but … • Little available from C++ exception object besides its type • Special syntax to catch all exceptions: • catch(. . .) will match any exception. • Good to use as the last catch in a group of catches. • Any object can be thrown in C++

  7. Few C++ library routinesthrow exceptions • Rather, to signal errors they use • Return codes • Global variables • Object states

  8. Other Considerations . . . • Exceptions should not be caught using call-by-value • Templates • Do not use throw list with any function template. • Inheritance • A handler for a base class exception can catch an exception object from a derived class.

More Related