Deleting a pointer...

K

kk

What happens if we delete a pointer twice ? Does the program always
crash or the behavior is undefined ?
 
J

Jerry Coffin

@g10g2000cwb.googlegroups.com>, (e-mail address removed)
says...
What happens if we delete a pointer twice ? Does the program always
crash or the behavior is undefined ?

Behavior is undefined -- you could only wish that it
crashed dependably.

Fortunately, if you use RAII, you rarely have to worry
much about it.
 
J

Jim Langston

kk said:
What happens if we delete a pointer twice ? Does the program always
crash or the behavior is undefined ?

Undefined behavior, but every time I've done it I've had a crash (luckily).
If you set the pointers value to 0 (or NULL) after you delete it nothing
happens, this is allowed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top