Also it's totaly legal to "delete" a null pointer. All the problems arise from the fact that including myself many forget to set the pointer to null after deletion.
Right. Actually everybody should use something like this all the time:
template<typename T> void Delete(T *p) {delete p; p = 0;};
Hmm... I really wonder why nobody does that. Something must be fundamentally wrong with this, that would be just too simple... :?:
One could use reference counted smart pointers to avoid above problem, too, of course.
If fact, I believe an object having a
Destroy() function
should necessarily be reference counted - if it only wraps around a plain normal
delete, then it is actually not of much use to have such a function.