The new operator in C++ throws an exception of type _______ when it fails to allocate memory. 

  • invalid_type 
  • bad_memory 
  • bad_alloc 
  • new_failure
In C++, if the new operator fails to allocate the requested memory, it throws an exception of type bad_alloc. This is especially useful in situations where robustness is necessary, as it allows programs to handle memory allocation failures gracefully.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *