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 are the extraction and insertion operators in c++?

742


Is it possible to use a new for the reallocation of pointers ?

778


What are the four main data types?

790


What is pointer -to-members in C++? Give their syntax?

774


How do we implement inheritance in c++?

805






What is this pointer in c++?

996


What is the use of seekg in c++?

786


What is microsoft c++ redistributable 2013?

768


What is the use of turbo c++?

747


Explain the difference between overloading and overriding?

837


How can you quickly find the number of elements stored in a dynamic array?

784


Why is it necessary to use a reference in the argument to the copy constructor?

833


Is java the same as c++?

724


Does dev c++ support c++ 11?

742


What is a rooted hierarchy?

861