C++ Inline Function

The objective of using function is to save memory. But, every time a function is called it takes lot of extra time in executing a series of instructions for tasks such as jumping arguments into the stacks and returning to the calling function.

In C, we have macro to overcome this situation but macro has some limitations like it is only one line.

In CPP, we have inline function to overcome this situation. When a function is declared inline the compiler replaces the function call with the respective function code. Inline function makes a program to run faster because the time of a function call and return is eliminated. A function can be defined as an inline function by prefixing the keyword inline to the function header.

Limitation of Inline Function

It makes the program to take more memory because the statement of inline function is reproduced at each point where the function is called. Normally, a small size function is made as inline.

C Language Feedback, Questions, Suggestions, Discussion.