check this out:
template<typename T>
void better_delete(T*& ptr) {
delete ptr;
ptr = 0;
}
you delete, and set the pointer to null. this way it's, say, safe to call
better_delete twice on the same pointer
"Xiaoshen Li" <> wrote in message
news:dp3lct$18mi$...
> Dear All,
>
> I thought I understood using pointer variables as function parameters.
> But I failed to understand why it is needed pass-by-reference of a
> pointer variable.
>
> To me, pointer variable is address variable, which holds the memory
> address of the object. Using a pointer variable as a function parameter,
> the function has the ability to CHANGE the object value pointed by the
> pointer. Why needs pass by reference?
>
> For example, I saw some code like the following:
>
> void myfunctionA(int* pA);
>
> void myfunctionB(int*& pA); //what is the advantage?
>
> Thank you very much.
>