Interactive Brokers Interview Question






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

I think its a clean way to start with. Since we Zero out the entire object space, we can make sure that un-initialized members of the class are not pointing to some junk data.

- Anonymous September 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what if class contain virtual function . then "this" pointer points to virtual table .
is not this also sets virtual ptr to 0?? plz correct me

- ridercoder October 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I can confirm your point. See:

#include <iostream>
#include <cstring>
using namespace std;

class Foo {
public:
	virtual void hello() const {
		cout << "Hello world" << endl;
	}
};

int main(void){
	Foo f;
	cout << sizeof(f) << endl;
	unsigned long* ptr = (unsigned long*)&f;
	cout << *ptr << endl;
	memset(&f, 0, sizeof(f));
	cout << *ptr << endl;
	
	return 0;
}

- Anonymous October 18, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

so can we inharit class and except same behaviour of overloadin?

- ridercoder October 18, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

NA

- weijiang2009 February 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

vptr

gets created in both kind of objects (statically created or dynamically created)

class base{
    int i;
    virtual void show() {..}
};

1. Statically created:

base b;

2. Dynamically created:

base *b = new base();

Point is when you access any virtual function through these objects then vptr is used or not.
case 1st :- Vptr is not used. So even if vptr is NULL, still virtual function can be called, because there is no polymorphism.
case 2nd:- Vptr is used. If Vptr is NULL , then calling to virtual function will give null pointer exception.

- ash.taunk3 October 28, 2014 | 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