Salesforce Interview Question for Developer Program Engineers


Country: India




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

here show function not accessing any data... so no problem..
if show function accessing some data of the class then it gives segmentation fault... because ob is null...

- Anonymous September 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

the fact that "show" is *not* a virtual function also helps...

- Anonymous September 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Null pointer can not be dereferenced irrespective of virtual or non virtual.

- Manish September 24, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

thats right, if we try to access class variable i it will crash because this pointer is NULL in show function

- Sirius April 28, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

This question was recently discussed on the comp.lang.c++.moderated newsgroup. Since links are not allowed here you might add the 'http' by yourself:
groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/3ad55a2ae79c569c/

- Anonymous October 29, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice articel at the link...

- is910 December 09, 2011 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

The basic reason why the above code works is as follows:

in C++ non virtual member function calls simliar to:

obj->functionName()

is expanded as

functionName(obj)

(remember the "this " pointer!!!? its the hidden first argument to all non-static member functions of a class.)

so now if u look at function call in given code, and the function expansion, its easy to see that it won't crash. Try making the function virtual or try accessing some member variables inside function. Then it will crash.

- Anonymous June 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

You cannot dereference a null pointer

- gavinashg September 23, 2011 | Flag Reply


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