what is inline function in c++

A function qualified as inline inform the compiler to insert the code of the function at the place of calling instead of jumping to the address of function to call.

#include <iostream>
using namespace std;
inline int add(int a, int b)
{
  return (a+b);
}

int main( )
{
   cout << "add(2,3): " << add(2,3) << endl;
return 0;
}

Note: Making a function inline is not a guaranty always to insert the code at called location. it depends on the size of function call and compiler settings , based on these parameters compiler takes decision to insert the code or to ignore inline code insertion.



Related Contents to follow