D
D. Susman
Hi,
When I call "clean" as shown below, shouldn't I be getting
segmentation fault due to garbage data? I am compiling with CC and the
output is 5. Does "delete" not delete in this situation or is it no
guarantee that it will print 5 or go wrong?
void clean( int* ptr )
{
delete ptr;
}
//...
int* ptr = new int( 5 );
clean( ptr );
cout << *ptr << endl;
When I call "clean" as shown below, shouldn't I be getting
segmentation fault due to garbage data? I am compiling with CC and the
output is 5. Does "delete" not delete in this situation or is it no
guarantee that it will print 5 or go wrong?
void clean( int* ptr )
{
delete ptr;
}
//...
int* ptr = new int( 5 );
clean( ptr );
cout << *ptr << endl;