Aricent Interview Question for Software Engineer in Tests






Comment hidden because of low score. Click to expand.
0
of 0 vote

there is no error in deleting a null pointer.

- Anonymous October 24, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

this can not go through the compiler, will throw an error.

Instead, if it is "delete p;", there will be an error for the "invalid pointer",, since the p was allocated before that.

- shoushou January 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ps, if the pointer is null, that's fine....

- shoushou January 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The C++ Standard states that it is perfectly valid to delete a null pointer.
So nothing would happen in the above case.

- Neo May 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Deleting a pointer means you are deallocating the space to the object which the pointer points to.
After using
{delete p;}

Pointer is still there and pointing to the same memory, but the memory may have different data now and may result in different behaviour of the pointer.

so it should be set to null after using delete pointer;
A pointer is deleted after the execution of the block like any other object.

(manish.kr85@yahoo.com)

- Manish April 25, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More