C++ Institute CPA-21-02 Question Answer
Given:
#include
#include
using namespace std;
int main () {
try
{
int * myarray= new int[1000];
}
catch (bad_alloc&)
{
cout << "Error allocating memory";
}
catch (exception& e)
{
cout << "Standard exception";
}
catch (...)
{
cout << "Unknown exception";
}
return 0;
}
What will happen if we use the operator “new” and the memory cannot be allocated?