I've read the following the following post Virtual dispatch implementation details and have only one thing not clear to me.
Given a polymorphic Base and a derive class - does the compiler duplicate the vftable per derive object? or all derived objects will point to the same vftable in the derived class memory space.
going into coding...
class B
{
public:
virtual void foo() = 0;
}
class D : public B
{
virtual void foo() {}
}
D object1;
D object2;
In the above code, will object1._vptr
will point to the same address as object2._vptr
? (which means _vptr[foo position]
will point to the same address in memory where foo
resides)