Ahmer H. answered 02/11/20
C++/Calculus/Physics 4.0 GPA holder here to help you out.
We can use Inline function as per our needs. Some useful recommendation are mentioned below-
- We can use the inline function when performance is needed.
- We can use the inline function over macros.
- We prefer to use the inline keyword outside the class with the function definition to hide implementation details of the function.
It really saves the compilation time. But it is to be only used when the involved functions are specific and short. For complex and large functions like one with loops, many errors may occur like cache misses. Now we dont want that to happen ,do we?
The main advantage of inline function is removal of function call . Since the time needed for the transfer of control is ignored thus the compilation becomes efficient and effective. Mostly it depends on compiler weather to use a function as inline or not.