The code above gives following error under MSVS .Net 2003:Code:#include <iostream>
using namespace std;
template <typename M>
void my_delete(M *&p)
{
if (p) delete p;
p = 0;
}
int main()
{
int* ptr;
cout << hex << ptr << endl;
ptr = new int;
cout << hex << ptr << endl;
my_delete(ptr);
cout << hex << ptr << endl;
return 0;
}
test4.cpp(17) : error C2664: 'my_delete' : cannot convert parameter 1 from 'int *' to 'void *& '
A reference that is not to 'const' cannot be bound to a non-lvalue