Can anyone explain me about virtual base class plz? Thank you :-) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Can anyone explain me about virtual base class plz? Thank you :-)

I was learning about visualising the base class in inheritance, to avoid the diamond problem(https://en.m.wikipedia.org/wiki/Multiple_inheritance). I learnt that it makes the most derived class to have only one copy of the base class. Even though I understood how it works, I wonder how it's done. I mean, how to works under the hood? How does C++ implement this logic? https://code.sololearn.com/cjW5C0ynyRLD/?ref=app

3rd Aug 2021, 2:33 AM
Rishi
Rishi - avatar
1 Answer
+ 3
Hernando Abella okay thank you. Just a little doubt here. How does c++ make it work? What logic does it use? I'm asking like, __vptr and virtual table is used to resolve virtual function calls, then what stuff is used to resolve this? Thank you again :)
3rd Aug 2021, 12:29 PM
Rishi
Rishi - avatar