C++ vtable resolving with virtual inheritance -


I was curious about C ++ and Virtual Heritage - in particular, the way to solve the Vitalical disputes between bass and child classes. I will not pretend to understand how I work, but what I have seen is that due to that resolution they are getting late due to the use of the virtual function. My question is that the base class is empty - that is, its virtual function is defined as:

  virtual vaude deust () = 0;  

Does this mean that resolution is not necessary, because there is only one group of functions to choose from?

I'm sorry if this is a stupid question - as I said, I do not understand how vtables work, so I really do not know in any way better.

Edit

So if I have two different child classes:

  a / \ / bc  

Compared to saying, there is no performance hit while calling functions from child organs, only one part is free class?

There is no hit to call the nonvirtual function in the child class If you are calling an override version of your pure virtual function as your example, then a virtual penalty can still exist. In general, except for very specific circumstances, it is difficult to remove the use of virtual table, where it knows (by context) in the context of the actual value of the object.

But do not worry about Don Overhead seriously. It is going to be very low that in practice you will almost certainly not face such a situation, where it is part of the code, due to which the performance barriers Are there. Use virtual functions where they understand your design and do not worry about (small) performance penalties.


Comments