+ 3
What is meant by Virtual Function Table in C++
Guys can anyone explain to me about VFT (Virtual Function Table in C++) , what is the use of it , where we use it and how to figure out VFT for a particular class in c++. Consider the below code for reference https://code.sololearn.com/cq05Xh0I7FDj/?ref=app
1 Antwort
+ 4
From my understanding, we don't need to directly use it. It is the implementation of the language to take care of which "version" of a (virtual) function is used by the class.
It is for classes that have inheritance and overridden functions. Just as your example shows, the most derived version of each function for that class is stored in the table of that class.
That is, the implementation of a function that is closest to the class.
For a certain function, the table will store a pointer to the first implementation that can be found in the order of:
1. The class itself, if it has implemented the function.
2. The parent of the class, if the parent has implemented the function.
3. The parent of the parent, if...
etc