compiler warning when assigning null to pointer
When i compile this code:
Code:
#include <iostream.h>
int main()
{
unsigned short *pnt=new unsigned short;
if (pnt==0)
{
cout<<"Not enough free memory available for pnt.";
return 0;
}
*pnt=7;
cout<<*pnt;
delete pnt;
pnt=0; //HERE IS THE PROBLEM
return 0;
}
I get a warning from my borland bcc32 5.5 compiler
that says: 'pnt' is assigned a value that is never used in function main()
I was told to take warnings seriously but the program works, and you should always assign pointers to point to null after calling delete on them. So...
...CAN I IGNORE THIS WARNING???