O'Reilly logo
  • Ilija Injac thinks this is interesting:

int ival = 1024;
int *pi = 0;      // pi is a valid, null pointer
int *pi2 = &ival; // pi2 is a valid pointer that holds the address of ival
if (pi)  // pi has value 0, so condition evaluates as false
    // ...
if (pi2) // pi2 points to ival, so it is not 0; the condition evaluates as


Cover of C++ Primer, Fifth Edition


Good explanation. Very important basics, to test for a valid pointer.