Question 6 Given the code below: class ExceptionA {}; class ExceptionB: public ExceptionA {}; class ExceptionC: public ExceptionA {}; void f1(int x) throw (ExceptionA, ExceptionB) { if (x % 2 != 0) throw ExceptionA (); throw ExceptionB(); } void f2 (int x) throw (ExceptionC, ExceptionA) { if (x <= 0) throw ExceptionC(); throw ExceptionA (); } } else void f3(int x) throw (ExceptionB, ExceptionC) { if (x 10) throw ExceptionB(); throw ExceptionC(); } else void f(void try { } else (*funcPointer) (int), int value) { funcPointer (value); } catch (ExceptionB) { cout << "Caught ExceptionB" << endl; } catch (ExceptionA) { cout << "Caught ExceptionA" << endl; } catch (ExceptionC) { } cout << "Caught ExceptionC" << endl; Write the output using the following main function: int main() { £ (£3, -10); £ (£3, 10); f(f2, -10); £ (£2, 10); f(f1, 20); f(fl, 11); return 0;
Question 6 Given the code below: class ExceptionA {}; class ExceptionB: public ExceptionA {}; class ExceptionC: public ExceptionA {}; void f1(int x) throw (ExceptionA, ExceptionB) { if (x % 2 != 0) throw ExceptionA (); throw ExceptionB(); } void f2 (int x) throw (ExceptionC, ExceptionA) { if (x <= 0) throw ExceptionC(); throw ExceptionA (); } } else void f3(int x) throw (ExceptionB, ExceptionC) { if (x 10) throw ExceptionB(); throw ExceptionC(); } else void f(void try { } else (*funcPointer) (int), int value) { funcPointer (value); } catch (ExceptionB) { cout << "Caught ExceptionB" << endl; } catch (ExceptionA) { cout << "Caught ExceptionA" << endl; } catch (ExceptionC) { } cout << "Caught ExceptionC" << endl; Write the output using the following main function: int main() { £ (£3, -10); £ (£3, 10); f(f2, -10); £ (£2, 10); f(f1, 20); f(fl, 11); return 0;
Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 20RQ
Related questions
Question
f18
In c++
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 3 images
Knowledge Booster
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.Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT