C++ Inline Function Question:

Download Job Interview Questions and Answers PDF

Explain inline function?

C++ Inline Function Interview Question
C++ Inline Function Interview Question

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 Interview Questions And Answers PDF

Previous QuestionNext Question
Define Inline Function?Explain static member functions?