Vidyalelo
C++ Programming · Q53

Exception Handling in C++

Programming · C++ Programming · question 53

Q53

What will be the output of the following C++ code? #include #include #include 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(B b) cout<<"Caught B Class "; catch(A a) cout<<"Caught A Class ";

A.
Caught B Class
Answer
B.
Caught A Class
C.
Compile-time error
D.
Run-time error

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board