An inline function is one for which the compiler copies the code from the
function definition directly into the code of the calling function rather than
creating a separate set of instructions in memory. Instead of
transferring control to and from the function code segment, a modified copy of
the function body may be substituted directly for the function call. In
this way, the performance overhead of a function call is avoided.
A function is declared inline by using the inline function
specifier or by defining a member function within a class or structure
definition.
The inline specifier is only a suggestion to the
compiler that an inline expansion can be performed; the compiler is free
to ignore the suggestion.
The following code fragment shows an inline function definition.
inline int add(int i, int j) { return i + j; }
The use of the inline specifier does not change the meaning of the
function. However, the inline expansion of a function may not preserve
the order of evaluation of the actual arguments. Inline expansion also
does not change the linkage of a function: the linkage is external by
default.