Wednesday, March 23, 2011

Inline Function

Implementation hiding can result in several small functions that manipulate the data in an object. Functions save memory space because all the calls to the function cause the same code to be executed.

When a compiler sees a function call, it usually jumps to the function. At the end of function it goes back to the instruction following the function call.

This series of events may save memory space but it takes some extra time. To save execution time in short function you may choose to put the code in the function body directly in line with the code in the calling program (ex. main function) .


An inline function is written just like a normal function in the source file but compiles into inline code instead of into a function.

However, when the program is compiled, the function body is actually inserted into the program wherever a function call occurs.

No comments:

Post a Comment