adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <exception>
    using namespace std;
    struct MyException : public exception
    {
        const char * what () const throw ()
        {
            return "C++ Exception";
        }
    };
    int main()
    {
        try
        {
            throw MyException();
        }
        catch(MyException& e)
        {
            cout << "Exception caught" << std::endl;
            cout << e.what() << std::endl;
        }
        catch(std::exception& e)
        {
        }    
    }

a.

C++ Exception

b.

Exception caught

c.

Exception caught

d.

Error

Answer: (c).Exception caught

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?