Nowadays, with C++11, Whats recommended to use, Zero
or NULL
? The first of the second if?
int * p = getPointer();
if( 0 == p ){
//
Neither, it's nullptr
.
Though, in your case, I'd just go with
if ( !p ){
//something
}
1 The pointer literal is the keyword
nullptr
. It is a prvalue of typestd::nullptr_t
. [ Note:std::nullptr_t
is a distinct type that is neither a pointer type nor a pointer to member type; rather, a prvalue of this type is a null pointer constant and can be converted to a null pointer value or null member pointer value.