Skip to Main Content
Professional C++, 3rd Edition
book

Professional C++, 3rd Edition

by Marc Gregoire
September 2014
Intermediate to advanced content levelIntermediate to advanced
984 pages
25h 22m
English
Wrox
Content preview from Professional C++, 3rd Edition

Chapter 13Handling Errors

  • How to handle errors in C++, including pros and cons of exceptions
  • The syntax of exceptions
  • Exception class hierarchies and polymorphism
  • Stack unwinding and cleanup
  • Common error-handling situations

Please note that all the code examples for this chapter are available as a part of this chapter’s code download on the book’s website at www.wrox.com/go/proc++3e on the Download Code tab.

Inevitably, your C++ programs will encounter errors. The program might be unable to open a file, the network connection might go down, or the user might enter an incorrect value, to name a few possibilities. The C++ language provides a feature called exceptions to handle these exceptional but not unexpected situations.

The code examples in this book so far have virtually always ignored error conditions for brevity. This chapter rectifies that simplification by teaching you how to incorporate error handling into your programs from their beginnings. It focuses on C++ exceptions, including the details of their syntax, and describes how to employ them effectively to create well-designed error-handling programs.

ERRORS AND EXCEPTIONS

No program exists in isolation; they all depend on external facilities such as interfaces with the operating system, networks and file systems, external code such as third-party libraries, and user input. Each of these areas can introduce situations which require responding to problems ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional C++, Second Edition

Professional C++, Second Edition

Marc Gregoire, Nicholas A. Solter, Scott J. Kleper
Expert C++ - Second Edition

Expert C++ - Second Edition

Marcelo Guerra Hahn, Araks Tigranyan, John Asatryan, Vardan Grigoryan, Shunguang Wu

Publisher Resources

ISBN: 9781118858134Purchase book