Interview Question


Country: United States




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

one for BASE class and one for DERIVED class

- Anonymous February 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Thanks

- Bharath February 08, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

1. I think vtables are related to at least classes but not to objects.
2. There is 1 vtable for Base, since there are virtual functions in it.
3. There would be 1 vtable for Derived, if it owns some virtual functions which are not in Base.
There are no vtables but vptrs in these objects. Vptrs are pointing to the same vtable. Vtables live as static datas.

- waiging.lau February 18, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Thanks :) This also answers where vtable is stored in memory.

- Bharath February 18, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

woww thankyou somuch

- Anonymous February 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class base {
 virtual fooA(){
 //something
}

class Derived : class base{
    virtual fooA(){
        //something different
    }
 
    void foo1(){ .. }
    ...
    void foo10(){ ...}


}

}

then
in base class: vtble : 1
in derived class: vtble : 11 <= 1 + 10

- peter April 10, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

every class will have its own virtual table. so only 1 virtual table.

- DashDash February 07, 2013 | 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