Virtual tables in C ++ are implementation details. One possible implementation is shown in the diagram below.

There are two instances of the class (A and B). Each instance has two vtbl pointers, and vtbl contains pointers to the actual code.
In your example, there is no instance data, but for illustrative purposes, it is assumed that each class contains instance data.
When pointing the pointer to Tester to the pointer to IFoo pointer is adjusted as shown in the diagram. Instead of pointing to the start of the instance data, it points to the IFoo part of the IFoo data.
It is clear that the caller using the IFoo pointer IFoo not know any information about the part related to the IFoo part of the class. The same can be said for the caller using the IPlugin pointer. This pointer points to the start of the instance data that the Tester pointer points to, but only the caller using the Tester pointer knows the entire layout of the instance data.
Using dynamic_cast requires RTTI (runtime type information), which is not shown in the diagram. Vtbl will contain additional type information that the IFoo pointer IFoo to the Tester instance, so that the code at runtime detects the actual type of the object that the pointer points to and uses it to lower the pointer.
source share