Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: C++
Expertise: All
Jan 7, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

To Virtual Or Not To Virtual?

You're probably aware of the overhead that is associated with calling a virtual member function. However, the performance penalty in this case might even be higher than you think because the comparison isn't always between static versus dynamic binding. Usually, compilers can't inline a virtual function call. Thus, the performance cost consists of the ordinary overhead associated with a function call plus the additional overhead of dynamic binding. Many programmers aren't aware of the double overhead when they declare virtual functions abundantly. As a rule, avoid declaring a member function virtual, unless it truly has to be virtual.

Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date