Answers

Question and Answer:

  Home  C++ Inline Function

⟩ Explain inline function?

An inline function is a combination of macro & function. At the time of declaration or definition, function name is preceded by word inline.

When inline functions are used, the overhead of function call is eliminated. Instead, the executable statements of the function are copied at the place of each function call. This is done by the compiler.

Consider following example:

#include <iostream>

using namespace std;

inline int sqr(int x)

{

int y;

y = x * x;

return y;

}

int main()

{

int a =3, b;

b = sqr(a);

cout <<b;

return 0;

}

 235 views

More Questions for you: