What are Inline Functions ? When are Inline Functions used ?
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
The idea behind inline functions is to insert the code of a called function at the point where the function is called. It is useful to distinguish between “inline,” a keyword qualifier that is simply a request to the compiler, and “inlined,” which refers to actual inline expansion of the function.
A function can be decorated with the inline keyword either in the class definition or in its own definition if the definition physically occurs before the function is invoked. The compiler does not promise that an inline function will be inlined, and the details of when/when not are compiler-dependent.
On the other hand, any function that is defined within the class body will be treated implicitly as an inline function with or without the explicit inline keyword. Inline code is faster than a function call for two reasons. First, a CALL instruction takes time to execute. Second, if there are arguments to pass, these have to be placed on the stack, which also takes time
Related Articles
- What are Virtual Functions ? Why do we need Virtual Functions? Explain with an example.
- What is a Pure Virtual Member Function ?
- What do you mean by “Pointers to Function”? What are Function Pointers ?
- What is Function Overloading in C++ ?
- What are Friend Functions and Friend Classes in C++ ?


