When I code as below, it'll return 'null' and no exception occured.
Char* pStr = new(std::nothrow)Char(10);
What about not using 'nothrow' argument on new operator? Does it also returns 'null'? If so, why is it recommended to use 'nothrow' argument?
Char* pStr = new Char(10);
Thanks for your time.
newwill throw an exception if it fails, unless you specifynothrow, in which case it will returnnullptrif it fails.As for why
nothrowis ever used: On some systems, exceptions aren't supported (or are badly supported) (this can be particularly true on gaming consoles). So it's best to not even use them at all. This is just one example whennothrowmay be used.