C++ Inline Function Question:

Explain inline function?

Tweet Share WhatsApp

Answer:

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;
}

Download C++ Inline Function PDF Read All 27 C++ Inline Function Questions
Previous QuestionNext Question
Define Inline Function?Explain static member functions?