You're just reinventing smart pointers that have existed for yonks. Read up on how to use Boost smart pointers. In fact, reserve a few days just to get an idea of what you can achieve with Boost, it's a huge library.
Uncertain fortune is thoroughly mastered by the equity of the calculation. - Blaise Pascal