Vidyalelo
C++ Programming · Q67

Exception Handling in C++

Programming · C++ Programming · question 67

Q67

What happens when this C++ program is compiled? #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(A a) cout<<"Caught A Class "; catch(B b) cout<<"Caught B Class ";

A.
The program compiles successfully without any errors or warnings
B.
Compile-time error occurs
C.
The program compiles successfully with warnings
Answer
D.
The program gives both errors and warnings

Answer: Option C

Solution

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