Why doesn\'t new return NULL on failure? Why does it throw an exception only on failure?
new
NULL
As it returns a pointer to the object on successes
you can specify that you want new to return 0 instead of throwing std::bad_alloc using the std::nothrow parameter:
std::bad_alloc
std::nothrow parameter:
SomeType *p = new(std::nothrow) SomeType;