What are the fields of vtable



What are the fields of vtable..

Answer / chandra

Vtable consists of function pointers pointing to the
virtual functions of their respective class.
Ex: Class A
{
public:
virtual void fun1();
virtual void fun2();
};
Class B: public A
{
public:
Virtual void fun2();
};

Now there will be 2 vtables created for the 2 classes. in
first vtable there will be 2 function pointers pointing to
fun1 and fun2.

one more vtable is created for the class B. in which this
vtable also consists of two function pointers because class
B is derived from class A. so all the functions are
derived . so in this vtable two function pointers are
present. one function pointer pointing to fun1 and one more
function pointer pointing to fun2 of derived class.

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More OOPS Interview Questions

what is polymorpsim? what are its types?

8 Answers  


Finding of the 4 larger (bigger) numbers from the list like{1245,4587,2145,1163,29987,65783.....}

1 Answers   Wipro,


Why do we use virtual functions?

4 Answers  


What are the components of marker interface?

0 Answers  


Can a destructor be called directly?

0 Answers  






What is a class oop?

0 Answers  


Precompilation ?

1 Answers   emc2,


How can i write a code in c# to take a number from the user and then find all the prime numbers till the number entered by the user.

4 Answers   NIIT, TCS,


What is for loop and its syntax?

0 Answers  


what is code for call by value and call by reference?

1 Answers  


Why is oop better than procedural?

0 Answers  


What polymorphism means?

0 Answers  


Categories