O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.2. Designing with Exceptions

The keyword try designates a try block, which is an area of your program that detects exceptions. Inside try blocks, we typically call functions that may raise or throw exceptions. The keyword catch designates a catch handler with a signature denoting an exception type. Catch handlers immediately follow try blocks or another catch handler with a different signature.

You must set up a try block and a catch handler to capture thrown exceptions. Otherwise, the exception is uncaught and your program terminates by default. Try blocks are important because their associated catch handlers determine what part of your program handles a specific exception. The code inside the catch handler is where you decide what to do ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required