Question: how vtable and vptr works in c++?
Answer: Each row of the vtable is a function pointer pointing to a corresponding virtual function. C++ compiler creates a hidden class member called virtual-pointer or in short vptr when there are one or more virtual functions. This vptr is a pointer that points to a table of function pointers.