Does the cost of virtual functions increase with the number of classes in the inheritance tree?
问题 Like the title says, e.g. does having 8 derived classes with virtual functions affect performances more than having 2 derived classes? And if so, is the difference negligible? And what about multiple inheritance (non virtual inheritance)? Thanks in advance. 回答1: The common implementation of dynamic dispatch in C++ is by means of a virtual table, which is basically an array of pointers to functions, one for each virtual function in the type. The length of the inheritance chain does not matter,