O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dealing with the New Exception

Handling this new exception requires a new function in the ErrorHandlingModule's SAMSErrorHandling namespace.

This function, shown in Listing 11.3, is pretty simple.

Listing 11.3. HandleRuntimeError() in ErrorHandlingModule
1:    int HandleRuntimeError(runtime_error theRuntimeError)
2:    {
3:       cerr <<
4:          theRuntimeError.what() <<
5:          endl;
6:
7:       return 1;
8:    }

Line 1 is the function header and shows the formal argument theRuntimeError, which is of type runtime_error. Line 4 uses the standard exception what() function to get the error message you put into the exception object in lines 14 and 15 of Accumulate(). Line ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required