(Throwing the Result of a Conditional Expression) Throw the result of a conditional ex- pression that returns either a double or an int. Provide an int catch handler and a double catch handler. Show that only the double catch handler executes, regardless of whether the int or the double is returned.

What will be an ideal response?


```
#include
using namespace std;

int main()
{
try // throw int
{
int a = 7;
double b = 9.9;

// throw int to show that only the double catch handler executes
throw a < b ? a : b;
} // end try
catch ( int x ) // catch ints
{
cerr << "The int value " << x << " was thrown\n";
} // end catch
catch ( double y ) // catch doubles
{
cerr << "The double value " << y << " was thrown\n";
} // end catch

return 0;
} // end main
```
The double value 7 was thrown

Computer Science & Information Technology

You might also like to view...

Select all that apply. Which of the following are special effects that can be applied to nodes in a scene graph?

a. a shadow appears behind a node b. a glow appears c. a shadow appears inside the edges of a node d. an image has a sepia tone appearance

Computer Science & Information Technology

The ________ property in Excel defines the cell to which the ListBox, ComboBox, and TextBox controls are bound

A) RowSource B) TextAlign C) Caption D) ControlSource

Computer Science & Information Technology

Which of the following is not an advantage of Linux?

a. Standardized operating system. b. Considerable vendor support. c. Many of the tasks performed on the system are unique to that version. d. The Linux approach is becoming the standard.

Computer Science & Information Technology

The input function returns a numeric value by default.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology