How the V-Table mechanism works?

Answer Posted / deepa balamurugan

If the both Base and the Derived class having the same
function then the Base class funtion should be declared as
virtual function. Then the C++ determines which function to
be called at the runtime based on the type of the object
pointed to by the Base pointer rather than the type of the
pointer.
As soon as the compiler reads the keyword virtual ,it will
create the vtable contains the address of the virtual
function inside that class and as soon as vtable is
created ,vptr is initialized to the proper vtable.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the arrow operator in c++?

550


which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?

706


What is the type of 'this' pointer?

587


Is string data type in c++?

573


Can we sort map in c++?

583






Which programming language should I learn first?

568


Can comments be nested?

611


Explain rtti.

579


What is the difference between #define debug 0 and #undef debug?

632


What is a null object in c++?

623


What is code reusability in c++?

654


Write a short code using c++ to print out all odd number from 1 to 100 using a for loop

574


What is a dynamic binding in c++?

520


Do inline functions improve performance?

626


Which software is best for programming?

650