I am little confused about vptr and representation of objects in the memory, and hope you can help me understand the matter better.
Consider
Binherits fromAand both define virtual functionsf(). From what I learned the representation of an object of class B in the memory looks like this:[ vptr | A | B ]and thevtblthatvptrpoints to containsB::f(). I also understood that casting the object fromBtoAdoes nothing except ignoring theBpart at the end of the object. Is it true? Doesn't this behavior is wrong? We want that object of typeAto executeA::f()method and notB::f().Are there a number of
vtablesin the system as the number of classes?How will a
vtableof class that inherits from two or more classes look like? How will the object of C be represented in the memory?Same as question 3 but with virtual inheritance.