17.2.2 Demonstrating Exception Handling
Figure 17.2 uses exception handling to wrap code that might throw a DivideByZeroException
and to handle that exception, should one occur. The user enters two integers, which are passed as arguments to function quotient
(lines 10–18). This function divides its first parameter (numerator
) by its second parameter (denominator
). Assuming that the user does not specify 0
as the denominator for the division, function quotient
returns the division result. ...
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.