- Does virtual inheritance use vTable? If yes or no, Then how it implemented
- How Virtual inheritance behave in memory?
- Any other alternative for virtual inheritance
Really appreciate a conceptual explanation.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Virtual inheritance is implemented in different way depending on the compiler.
1) Yes, both vc and gcc use vTable pointer. But vc has another pointer ref as virtual base pointer.
2) For a classical virtual inheritance, like Left < Top; Right < Top; Bottom < Left and Right
The stack should be like this:
Programs use vptr to find vtable, for gcc, there is a virtual base offset value in viable. vptr + base offset will give the parent address.
3) I’m not sure what do you mean. There are different ways to implement it in C++ compilers. And other languages have their ways to bind functions.