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

This is a standard exception handler used in the class.



Your comments will be displayed only after manual approval.