Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
9th Edition
ISBN: 9780133862218
Author: Walter Savitch
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 16.1, Problem 9STE

What is the output produced by the program in Self-Test Exercise 8 if the following change were made to the program? Change

sampleFunction(98.6);

in the try block to

sampleFunction(212);

8. What is the output produced by the following program?

#include <iostream>

using namespace std;

void sampleFunction(double test) throw (int);

int main()

{

try

{

cout << "Trying.\n";

sampleFunction(98.6);

cout << "Trying after call.\n";

}

catch(int)

{

cout << "Catching.\n";

}

cout << "End of program.\n";

return 0;

}

void sampleFunction(double test) throw (int)

{

cout << "Starting sampleFunction.\n";

if (test < 100)

throw 42;

}

Blurred answer
Students have asked these similar questions
I am having a hard time understanding the output of this program with shadow and deep binding. Can someone explain it more in detail? I posted the answers below   x : integer – – globalprocedure set x(n : integer)x := nprocedure print x()write integer(x)procedure foo(S, P : function; n : integer)x : integer := 5if n in {1, 3}set x(n)elseS(n)174 Chapter 3 Names, Scopes, and Bindingsif n in {1, 2}print x()elsePset x(0); foo(set x, print x, 1); print x()set x(0); foo(set x, print x, 2); print x()set x(0); foo(set x, print x, 3); print x()set x(0); foo(set x, print x, 4); print x()   Here are the answers to the questions.     The program prints = 10 20 30 40 with shallow binding The program prints = 10 52 00 44 with deep binding,
What is the output of the following C++ code? #include <iostream>using namespace std;class A{public:A(int n ){cout << n;}};class B: public A{public:B(int n, double d): A(n){cout << d;}};class C: public B{public:C(int n, double d, char ch): B(n, d){cout <<ch;}};int main(){C c(5, 4.3, 'R');return 0;}
What is the output of the following C++ code?   #include <iostream> using namespace std; class A { public: A(int n ) { cout << n; } }; class B: public A { public: B(int n, double d) : A(n) { cout << d; } }; class C: public B { public: C(int n, double d, char ch) : B(n, d) { cout <<ch; } }; int main() { C c(5, 4.3, 'R'); return 0; }
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
.2: Function Parameters and Arguments - p5.js Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=zkc417YapfE;License: Standard Youtube License