Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include <iostream>
    #include <exception>
    using namespace std;
    class NewExcep: public exception
    {
    virtual const char* what() const throw()
    {
    return "New exception occurred...";
    }
    } NewExcep;
    int main ()
    {
    try
    {
    throw NewExcep;
    }
    catch (exception& excep)
    {
    cout << excep.what() << endl;
    }
    return 0;
    }
    1. Exception
    2. Compilation Error
    3. New exception occurred...
    4. Runtime Error
    5. None of these
Correct Option: C

This is a type of exception arising in the class. We can call this
also as a standard exception.



Your comments will be displayed only after manual approval.