CS202 5- ‹#›
Exceptions w/ Classes
nThis change requires that the client program catch and handle the error and determine how to handle it.
nThe class no longer performs error processing.
nThis approach gives the client program control of how errors are handled and the type of error messages provided.
nTo detect when new fails, we use the regular form of new. If new cannot allocate the necessary space, it automatically throws an exception of type bad_alloc. If the index is out of bounds, we throw an exception instead of returning.
nTherefore, we do not need a dummy integer to return. But, we do need to define a type for the exception that is thrown (bad_index structure).