Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    #include
    #include
    void Function()
    {
    cout << "Function() was called by terminate()." << endl;
    exit(0);
    }
    int main()
    {
    try
    {
    set_terminate(Function);
    throw "Out of memory!";
    }
    catch(int)
    {
    cout << "Integer exception raised..." << endl;
    }
    return 0;
    }
    1. Compilation Error
    2. Runtime Error
    3. Integer exception raised...
    4. Function() was called by terminate().
    5. None of these
Correct Option: D

As there is no integer in this program, We are printing Function() was called by terminate().



Your comments will be displayed only after manual approval.