Vidyalelo
C++ Programming · Q55

Exception Handling in C++

Programming · C++ Programming · question 55

Q55

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 func1() B b; throw b; void func2() A a; throw a; int main() try func1(); catch(...) cout<<"Caught All types of exceptions "; try func2(); catch(B b) cout<<"Caught All types of exceptions ";

A.
Caught All types of exceptions
B.
Caught All types of exceptions
Aborted (core dumped)
Answer
C.
Error
D.
Caught All types of exceptions
Caught All types of exceptions

Answer: Option B

Solution

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