An inline function is a function whose code gets inserted into the caller's code stream. Like a macro, inline functions improve performance by avoiding the overhead of the call itself and (especially!) by the compiler being able to optimize THROUGH the call ("procedural integration"). Unlike macros, inline functions avoid infamous macro errors by evaluating all arguments exactly once (the "call" is semantically like a regular function call, only faster). Also unlike macros, argument types are checked, and necessary conversions are performed correctly (macros are bad for your health; don't use them unless you absolutely have to).
Beware that overuse of inline functions can cause code bloat, which can in turn have a negative performance impact in paging environments.
They are declared by using the "inline" keyword when the function is defined:
inline void f(int i, char c) /*...*/
or by including the function definition itself within a class:
class Fred { public: void f(int i, char c) { /*...*/ } };or by defining the member function as "inline" outside the class:
class Fred { public: void f(int i, char c); }; inline void Fred::f(int i, char c) { /*...*/ }