Aricent Interview Question
Software Engineer in TestsSo nitest, anytime I get an Access Violation, is it because of deleting twice?
It is called a double delete. Depending on the implementation of the memory manager, it may or may not cause an Access Violation. Calling this as "Access Violation" is pretty silly. Acess Violation is something that _might_ happen as a result of double delete.
Calling it a dangling pointer is backwards. It is something which hasn't been deleted at all.
Best way to avoid double deletes is to move to C# or Java :).
If that cannot be done, use auto_ptr like class.
If you cannot do that, code more carefully, set it to NULL after delete etc. But, if you aren't using auto_ptr, expect bugs in the code.
Just shut your mouth up and stop giving suggestions regarding C# and Java. Answer only what is answered!
Wow! I am amazed at your abiwity to extract a concise summary of what others are tawking about.
I have to disagree on one point though, if I answer what is awready answered, I won't add much to the discussion, would I?
Yours truwy,
your son.
i guess it called access violation error.
- nitesh October 24, 2008to avoid such errors make the value of pointer to null just after deleting it, that way it will be ignored by the next delete operation( no-op ) and the error can avoided.