C++ Virtual Functions Question:

Download Job Interview Questions and Answers PDF

Do you know the use of Vtable?

C++ Virtual Functions Interview Question
C++ Virtual Functions Interview Question

Answer:

Vtables are used for virtual functions. Its a shortform for Virtual Function Table.

It's a static table created by the compiler. Compiler creates a static table per class and the data consists on pointers to the virtual function definitions. They are automatically initialised by the compiler's constructor code.

Since virtual function pointers are stored in each instance, the compiler is
enabled to call the correct vrtual function at runtime.

Download C++ Virtual Functions Interview Questions And Answers PDF

Previous QuestionNext Question
What is Dynamic Binding?What is virtual base class?