C++ | Exception Handling | Question 4
Output of following program
(A) Caught Derived Exception
(B) Caught Base Exception
(C) Compiler Error
Explanation: If both base and derived classes are caught as exceptions then catch block of derived class must appear before the base class. If we put base class first then the derived class catch block will never be reached.
In Java, catching a base class exception before derived is not allowed by the compiler itself. In C++, compiler might give warning about it, but compiles the code.
Quiz of this Question