-
What is the output of this program?
#include <iostream>
#include <exception>
using namespace std;
void Function ()
{
cout << "Unexpected called\n";
throw 0;
}
void myfunction () throw (int)
{
throw 'L';
}
int main ()
{
set_unexpected (Function);
try
{
myfunction();
}
catch (int)
{
cout << "Caught int\n";
}
catch (...)
{
cout << "caught other exception\n";
}
return 0;
}
-
- Caught int
- Unexpected called
Caught int - Unexpected called
- Caught int
Unexpected called - None of these
Correct Option: B
As we are calling set_unexpected (myunexpected) function, this is printing as unexpected called and because of operator compliance it is arising an exception.