Answer to Question #544 in C++ for Neddy
Why it is considered that the virtual functions are slow?
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.
No comments. Be first!