Non-virtual vs virtual function call efficiency in C++ -


this question has answer here:

reading virtual functions, have come across following concept: "c++ non virtual function calls resolved @ compile time static binding, while virtual function calls resolved @ runtime dynamic binding."

my questions are: 1)would have large effect on performance then, if had large number of virtual function calls in our program, since evaluated @ runtime? or not relevant in modern machines?

2)is number dependent on stack?

generally speaking, cost of referencing vtable function address object negligible.

but, else, depends on application. rule of thumb if designing class know speed-critical, think type of issue. otherwise, worry bigger things.


Comments