Why two vfptr incase of virtual inhertance?
-
Hi all. Here are the two classes one base and other Derived ( virtually inherited from Base) Class Base { Public: Virtual void FunB(){} }; Class Derived: virtual public Base { Public: Virtual void FunD(){} }; When I derived class Derived virtually from Base, and when I saw the memory layout of objects of Derived in debug window; I saw two separate vfptrs; one for Base and one for Derived. But if I do not derive class Derived virtually from Base, then there is only single vfptr in object of Derived class? Why an extra vfptr is added/required in case of virtual inheritance?
Sameer Thakur
-
Hi all. Here are the two classes one base and other Derived ( virtually inherited from Base) Class Base { Public: Virtual void FunB(){} }; Class Derived: virtual public Base { Public: Virtual void FunD(){} }; When I derived class Derived virtually from Base, and when I saw the memory layout of objects of Derived in debug window; I saw two separate vfptrs; one for Base and one for Derived. But if I do not derive class Derived virtually from Base, then there is only single vfptr in object of Derived class? Why an extra vfptr is added/required in case of virtual inheritance?
Sameer Thakur
Sameer_Thakur wrote:
Why an extra vfptr is added/required in case of virtual inheritance?
No, I could not see, if it is added ? Which version of VS you are using ? P.s. Ask this question in VC++ forum, where it is suited.
Prasad MS MVP - VC++