Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include <iostream>
    #include <exception>
    using namespace std;
    void terminatorFunction()
    {
    cout << "terminate" << endl;
    }
    void (*old_terminate)() = set_terminate(terminatorFunction);
    class BotchClass
    {
    public:
    class Fruits {};
    void f()
    {
    cout << "First" << endl;
    throw Fruits();
    }
    ~BotchClass() noexcept(false)
    {
    throw 'U';
    }
    };
    int main()
    {
    try
    {
    BotchClass obj;
    obj.f();
    }
    catch(...)
    {
    cout << "inside catch(...) block" << endl;
    }
    }
    1. Aborted
    2. terminate
    3. First
    4. inside catch(...) block
    5. None of these
Correct Option: A

This program uses set_terminate as it is having an uncaught exception.



Your comments will be displayed only after manual approval.