-
Book Overview & Buying
-
Table Of Contents
Deciphering Object-Oriented Programming with C++ [WARNING: NOT FOR USE IN OTHER MATERIAL/SEE CONTRACT]
By :
Now that we can create drivers to test each class (or a grouping of related classes), we will want to understand which methods in our code may throw exceptions. For these scenarios, we will want to add try blocks within the driver to ensure we know how to handle each potential exception thrown. Before doing so, we should ask ourselves, did we include adequate exception handling in our code during the development process? For example, considering instantiation, do our constructors check whether an object is fully constructed? Do they throw exceptions if not? If the answer is no, our classes may not be as robust as we had anticipated.
Let’s consider embedding exception handling into a constructor, and how we may construct a driver to test all potential means for instantiation.
We may recall from our recent Chapter 11, Handling Exceptions, that we can create our...