Answer to Question #544 in C++ for Neddy

Question #544
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.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS