Referencing the multiple inheritance memory layout, suppose Derived
class has a field called int derived_only
. If I have a Base1 * b1
and Base2 * b2
, both pointing to the same Derived
class object, then according to wiki, b1
and b2
have slightly different values due to pointer fixup. My question is, if I call a virtual function, say the virtual clone()
, by using either b1
or b2
, how does clone()
calculate derived_only
's address, from either b1
or b2
?
Basically, when calling b1->clone()
vs b2->clone()
, the this
pointer passed in is different, then how does clone()
know how much offset to add to this
to get to derived_only
?