Question: A standard Hello World type example for exception handling is divide by zero. a. Write C++ code that creates a (trivial) class for a DivideByZero

 A standard "Hello World" type example for exception handling is divide

A standard "Hello World" type example for exception handling is divide by zero. a. Write C++ code that creates a (trivial) class for a DivideByZero exception. b. Using that class, write the prototype for a C++ function named rationalAsDouble that takes two args, int numerator, and int denominator. It coverts these two integers as a fraction into a double. The function should throw a DivideByZero exception if the denominator is zero. Be sure that the function prototype declares that the function may throw the DivideByZero exception (see pp. 911-913 for the syntax.) c. Now write the full function definition for rationalAsDouble that throws the necessary exception if the denominator is zero. Otherwise, it carries out the division and returns the value as a double

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!