Normally if we use new() to allocate the memory , if it fails it will return an exception unlike the memalloc() which will return a NULL pointer, which leads to Program Crash.
To achieve the Same functionality with the new() we have to use std::nothrow
Usage is like this :
int *p=new( std::nothrow) int(10);
in the Above case it will return NULL instead of Exception ... so failing of new() will not affect the Program Execution....
No comments:
Post a Comment