I have got some code which uses a lot of pointers pointing to the same address. Given a equivalent simple example:
int *p = new int(1); int *q = p; int *r =
The "modern" answer is to use a smart pointer and don't do any manual deletes.
boost::shared_ptr p(new int(1)); boost::shared_ptr q = p; boost::shared_ptr r = q;
End of story!