Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    void Example() throw()
    {
    cout << "In empty()" << endl;
    }
    void WithTypeFunction() throw(int)
    {
    cout << "Will throw an int" << endl;
    throw(1);
    }
    int main()
    {
    try
    {
    Example();
    WithTypeFunction();
    }
    catch (int)
    {
    cout << "Caught an int" << endl;
    }
    }
    1. Caught an int
    2. In empty()
    3. Will throw an int
    4. All of above
    5. None of these
Correct Option: D

It will print all three because we are calling all functions in the main().



Your comments will be displayed only after manual approval.