extern const nothrow_t nothrow;
new
operator is used to attempt to allocate memory and the handling function is unable to do so, a bad_alloc exception is thrown. But when nothrow is used as argument for new
, it returns a null pointer instead.operator new
function can be overloaded to take more than one parameter: The first parameter passed to the operator new function is always the size of the storage to be allocated, but additional arguments can be passed to this function by enclosing them in parentheses in the new-expression. For example:
|
|
|
|
new[]
operator and function operator new[].
|
|
Attempting to allocate 1 MiB... Succeeded! |