Why it is considered that the virtual functions are slow?
1
Expert's answer
2010-08-05T09:52:16-0400
It is so, because the additional time is spent for the search of the desired function address. Each object has a pointer to a virtual function table. This table is looked for the needed function and the detected function is called. In fact, the losses are not so great. New compilers are very good in optimizing the storage addresses of the virtual functions and their search. And even in the new processors some changes were made in order to make a call of the function from the indirect address faster.
Comments
Leave a comment