Suppose we have a base class Aand derived class B.
A implements a virtual method foo() which is overloaded in B.
If we have an object test of type B, then the object would surely contain both implementations of foo(). When we call the method, how is the correct (most derived) method found?
Would the vptr contained in the base class come into use perhaps...?
A, would typically not be involved in method invocations on aBinstance. When a client invokesA::foo, on aBinstance,B's vtable alone is sufficient to direct execution toB::foo. When theB::fooimplementation invokes its parentA::foo, this is a direct call bypassing virtual dispatch (so here neitherA's norB's vtable is accessed).