A Type System for Static and Dynamic Checking of C++ Pointers