Question: In addition to including an exceptions library, you can also create exceptions by using the throw keyword. (1pt) Create a function called int throwsInt() that

In addition to including an exceptions library, you can also create exceptions by using the throw keyword.

(1pt) Create a function called int throwsInt() that will throw an integer

(1pt) Create a function called double throwsDouble() that will throw a double

(2pt) Using try/catch statements, expand the code stubs to call each function in it's own try block, and catch and report the thrown value.

Provided code:

#include

using namespace std;

int throwsInt();

double throwsDouble();

int main() { cout << "about to run throwsInt()" << endl; try { int val = throwsInt(); cout << "val: " << val << endl; } catch (int i) { cout << "Caught integer: " << i << endl; } cout << "about to run throwsDouble()" << endl; // Build your try/catch based on the example above! }

int throwsInt() { //implement this function here }

double throwsDouble() { //implement this function here }

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!