What will be the output of the following C++ code?
#include <iostream>
using namespace std;
#include <cstdlib>
#include <exception>
void Funct()
{
cout << "Funct() was called by terminate()." << endl;
exit(0);
}
int main()
{
try
{
set_terminate(Funct);
throw "Out of memory!";
}
catch(int)
{
cout << "Integer exception raised." << endl;
}
return 0;
}
#include <iostream>
using namespace std;
#include <cstdlib>
#include <exception>
void Funct()
{
cout << "Funct() was called by terminate()." << endl;
exit(0);
}
int main()
{
try
{
set_terminate(Funct);
throw "Out of memory!";
}
catch(int)
{
cout << "Integer exception raised." << endl;
}
return 0;
}A. Integer exception raised
B. Funct() was called by terminate()
C. Integer exception not raised
D. Integer exception raised.
Answer: Option B

Join The Discussion