Virual table will be created only if at least 1 virtual function is there in the Base class, which will be any way inherited to the derived classes. It doesn't matter even if you remove virtual keyword from derived class B because already u are having a virtual fun() in A.
So the number of virtual tables will be 2 (as its per class basis) and number of virtual ptrs will also be 2, as its per object basis. VTABLE for A---v_ptr* , A::fun()
& VTABLE for B--- V_ptr*(which was inherited from A),B::fun()/* B have access to both A::fun & B's fun(), but since we mentioned A::fun() as virtual B's virtual table is filled with the most derived version of the function, fun(), which is nothing but B::fun(). Hope this clears your doubt,
main
, and thus realizing that (despite of thevirtual
declaration) no dynamic binding is being used. So it would not create the tables. Actually it would remove all the code. I see that https://mcmap.net/q/842812/-number-of-virtual-tables-and-virtual-pointers-in-a-c-program said the same. – Holston