Bloomberg LP Interview Question for Financial Software Developers






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

aka Dynamic binding.

Typically, the pointer's type determines the function calls. However, virtual functions let the object (not pointer) determines function called.
The base type pointer, calls the method but the proper virtual function at runtime is called (dynamically).

Declare a function as virtual in base class, then override it in each derived class, just like redefining, new function must have same signature. If function declared virtual, can only be overridden. Once declared virtual, a function is virtual in all derived classes. It's a good practice to explicitly declare virtual though.

Dynamic binding chooses proper function to call of the virtual address table at runtime, but it only occurs off pointer handles. If function called from object, it uses that object’s definition.

- Anonymous July 27, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think the answer should be in terms of v-table and v-pointer.

A virtual-table is created for every class having one or more virtual functions. The
virtual table is usually implemented as an array of function pointers where each function pointer corresponds to the various implementations of the virtual function by the derived classes.

When an object of this class is created, it contains a virtual-pointer (v-pointer) which points to the start of v-table. Whenever a virtual function is invoked on this object, the runtime system resolves it by following the v-pointer to the v-table to invoke the appropriate function.

- Nitesh October 02, 2009 | 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