|
By Alex, on October 26th, 2008 As with almost everything that has benefits, there are some potential downsides to exceptions as well. This article is not meant to be comprehensive, but just to point out some of the major issues that should be considered when using exceptions (or deciding whether to use them).
Cleaning up resources
One of the biggest problems . . . → Read More: 15.6 — Exception dangers and downsides
By Alex, on October 26th, 2008 Exceptions and member functions
Up to this point in the tutorial, you’ve only seen exceptions used in non-member functions. However, exceptions are equally useful in member functions, and even moreso in overloaded operators. Consider the following overloaded [] operator as part of a simple integer array class:
|
int IntArray::operator[](const int nIndex) { return m_nData[nIndex]; } |
Although this function will work great as . . . → Read More: 15.5 — Exceptions, classes, and inheritance
By Alex, on October 25th, 2008 By now, you should have a reasonable idea of how exceptions work. In this lesson, we’ll cover a few more interesting exception cases.
Uncaught exceptions
In the past few examples, there are quite a few cases where a function assumes its caller (or another function somewhere up the call stack) will handle the exception. In . . . → Read More: 15.4 — Uncaught exceptions, catch-all handlers, and exception specifiers
By Alex, on October 5th, 2008 In the previous lesson on basic exception handling, we explained how throw, try, and catch work together to enable exception handling. This lesson is dedicated to showing more examples of exception handling at work in various cases.
Exceptions within functions
In all of the examples in the previous lesson, the throw statements were placed directly . . . → Read More: 15.3 — Exceptions, functions, and stack unwinding
By Alex, on October 4th, 2008 In the previous lesson on introduction to exceptions, we talked about how using return codes causes you control flow and error flow to be intermingled, constraining both. Exceptions in C++ are implemented using three keywords that work in conjunction with each other: throw, try, and catch.
Throwing exceptions
We use signals all the time in . . . → Read More: 15.2 — Basic exception handling
By Alex, on October 4th, 2008 In the previous lesson on handling errors, we talked about ways to use assert(), cerr(), and exit() to handle errors. However, we punted on one further topic that we will now cover: exceptions.
When return codes fail
When writing reusable code, error handling is a necessity. One of the most common ways to handle potential . . . → Read More: 15.1 — The need for exceptions
|
|