Nowadays, with C++11, Whats recommended to use, Zero
or NULL
? The first of the second if?
int * p = getPointer();
if( 0 == p ){
//
If you have the same problem in 2019, You are using an older initialization style for unassigned pointers. After 2014 August 14 the C++ 11 released. The compiler you are using is probably following the C++11 standard.
You can just replace
0/NULL
withnullptr
Modern C++ offers nullptr
as a universal null pointer. You should use that instead of 0 || NULL
because there are some obscure machines that have things like signed pointers where a null pointer is actually something like -1 rather than 0.