C ++ What is faster? static member function or regular?

I'm trying to do some things ... this question may seem silly, but I will try. Suppose each function has 100 lines of the same code. or does this difference not reach the real level? which will be faster to execute in the main function:

 struct A { static void f() { cout << "static one"; } }; 

or this one:

 void f() { cout << "non static"; } int main() { A::f(); f(); } 
+4
source share
1 answer

It makes no difference, the compiler develops the address at compile time and sends it one step at run time (if it does not embed it, which is equally capable / possible to do with it).

+9
source

Source: https://habr.com/ru/post/1389624/


All Articles