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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started