-
What is the output of this program?
#include <iostream>
#include <exception>
using namespace std;
void Function()
{
cout << "Unexpected handler called\n";
throw;
}
void NewFunction () throw (int,bad_exception)
{
throw 'U';
}
int main (void)
{
set_unexpected (Function);
try
{
NewFunction();
}
catch (int)
{
cout << "caught int\n";
}
catch (bad_exception be)
{
cout << "Caught Bad_exception\n";
}
catch (...)
{
cout << "Caught other exception \n";
}
return 0;
}
-
- Unexpected handler called
- Unexpected handler called
Caught Bad_exception - Caught Bad_exception
- Caught Bad_exception
Unexpected handler called - None of these
Correct Option: B
In this program, We are calling set_unexpected and NewFunction, So it is printing the output.