?
What will be the output of the following C++ code?
What will be the output of the following C++ code?
#include <iostream>
#include <exception>
using namespace std;
int main()
{
try
{
int * array1 = new int[100000000];
int * array2 = new int[100000000];
int * array3 = new int[100000000];
int * array4 = new int[100000000];
cout << "Allocated successfully";
}
catch(bad_alloc&)
{
cout << "Error allocating the requested memory." << endl;
}
return 0;
}
#include <iostream>
#include <exception>
using namespace std;
int main()
{
try
{
int * array1 = new int[100000000];
int * array2 = new int[100000000];
int * array3 = new int[100000000];
int * array4 = new int[100000000];
cout << "Allocated successfully";
}
catch(bad_alloc&)
{
cout << "Error allocating the requested memory." << endl;
}
return 0;
}
Join the Discussion
Login to post a comment or share your explanation.
Login