adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <exception>
    using namespace std;
    class myexception: public exception
    {
        virtual const char* what() const throw()
        {
            return "My exception";
        }
    } myex;
    int main () 
    {
        try
        {
            throw myex;
        }
        catch (exception& e)
        {
            cout << e.what() << endl;
        }
        return 0;
    }

a.

Exception

b.

Error

c.

My exception

d.

runtime error

Answer: (c).My exception

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?