void DeletePointer(int& pointer); //could template this
int main()
{
int* yum = new int;
*yum = 50;
DeletePointer(yum);
}
DeletePointer(int& pointer) //are references to points even possible?
{
delete pointer;
pointer = 0; //make it point to nothing
}
If this is allowed (I'm about to test it), is it good coding practice to do so?
---ConPong _//_ Google _//_ Chaos Forge - quick and easy file hosting for developers
"Games usually keep me from making my own..."
-Me
--- EDIT:
#include <iostream>
using namespace std;
void DeletePointer(int* pointer); //could template this
int main()
{
int* yum = new int;
*yum = 50;
DeletePointer(yum);
yum = new int[4];
*(yum + 2) = 5;
cout << *(yum + 2) << endl;
system("pause");
return 0;
}
void DeletePointer(int* pointer)
{
delete pointer;
pointer = 0; //make it point to nothing
}
This seems to work, I want someone who knows what they are doing to double check it though.