bad_alloc standard exception : new delete « Development « C++






bad_alloc standard exception

   
#include <iostream>
#include <exception>
using namespace std;

int main () {
  try
  {
    int* myarray= new int[1000];
  }
  catch (exception& e)
  {
    cout << "Standard exception: " << e.what() << endl;
  }
  return 0;
}
  
    
    
  








Related examples in the same category

1.delete memory allocate for objects
2.Use new operator to allocate memory for object
3.Demonstrating new throwing bad_alloc when memory is not allocated