From “New and delete (C++)” on Wikipedia:
If not enough memory is available in the free store for an object of type
T
, thenew
request indicates failure by throwing an exception of typestd::bad_alloc
. This removes the need to explicitly check the result of an allocation.
2
solved what happens if I call new in c++, but the heap is out of memory? [closed]