13. Exception Handling in C++

Overview

This chapter introduces exception handling, the mechanism used by C++ for reporting and recovering from unexpected events in a program. By the end of this chapter, you will be able to recognize the kinds of events for which exception handling is appropriate; know when to throw exceptions and when to return an error code; write robust code using exception handling; Use RAII with exception handling to automatically reclaim resources after an unexpected event; and recover from and continue execution after unexpected events.

Introduction

Previous chapters introduced C++ flow-of-control statements and variable declarations. We have had a taste of object-oriented programming and created data structures ...

Get The C++ Workshop now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.