As title says, i know that new throws an exception which can be caught, but what exactly happens to the pointer? it turns NULL? I checked some answers on SO but none explain
If new
fails it throws a std::bad_alloc
exception, unless you use the nothrow
version. This means that the value of the variable to store the returned pointer will be unchanged.
If you catch the exception the value of pFile
remains uninitialized, otherwise your application terminates (as main
is exited)