What are the fields of vtable

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What does it mean when someone says I oop?

840


What is difference between oop and pop?

901


What is inheritance in simple words?

840


What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }

2242


What is difference between inheritance and polymorphism?

802


What is polymorphism and why is it important?

807


Why do we use encapsulation in oops?

779


What makes a language oop?

847


Give an example where we have to specifically use C programming language and C++ programming language cannot be used?

1411


Can we create object of interface?

870


What is the difference between a constructor and a destructor?

883


What is the main feature of oop?

920


Can we define a class within the interface?

814


What is overriding in oops?

852


Whats oop mean?

813