Home / MCQ Bank / Computer
Computer Exception Handling In C Plus Plus Difficulty: Medium

What happens when this C++ program is compiled? #include <iostream> #include <string> #include <cstdlib> using namespace std; class A { int a; public: A(){} }; class B: public A { int b; public: B(){} }; void func() { B b; throw b; } int main() { try{ func(); } catch(A a){ cout<<"Caught A Class\n"; } catch(B b){ cout<<"Caught B Class\n"; } }

Select the correct option to test your answer:

More Computer Questions

What will be the output of the following C code? #include <stdio.h> void main() { int x = 4; int *p = &x; int *k = p++; int r = p - k; printf("%d", r); } What is the method used to check if an object is an instance of a particular class in Ruby? How many digits is the DECIMAL used for expressions containing only exact values with fractional part? EC2 capacity can be increased or decreased in real time from as few as one to more than . . . . . . . . virtual machines simultaneously. What functionality does the itertools module in Python offer?