+ 1
What is inline member function in C++?
Please explain the function of 'Inline Member Function'? How does it works? What will happen if i use 'void' in place of 'inline'?
1 Answer
+ 2
Inline functions are somewhat similar to Macros, if you have heard of them.
In C++, when a functional is called, currently executing function is set aside by saving all the working variables to a stack, and start executing the calling function. There is a little bit of overhead in doing house keeping stuff like saving the context, switching the context to the new function and returning to the old context.
Inline functions reduces this overhead. The C++ compiler tries to replace their code into the calling function itself so that the context switching time is reduced.
Normally simple functions are declared inline and this is only a signal to the compiler to make it inline. It can decide whether to really expand the function inline or not. Functions with loops, and recursion are not candidates for replacing inline.
For more info, http://www.cplusplus.com/articles/2LywvCM9/