‘inline’ keyword

Advantage of using the keyword ‘inline’ before a function:

The member functions of a class may be defined inside the class definition or outside the class using scope resolution operator. The functions defined inside a class are inline by default. Generally, the functions, which are small, are defined inside a class definition.

If a function defined outside the class intends to be inline, then inline keyword is used before the function, as shown below:

class A
{       int x;
public:
void getx();
int square(int);
};

inline int A :: square(int a)
{
return(a*a);
}

With inline keyword the function call will be replaced by the function code by the compiler. But it is upon the wish of compiler to make any function inline or not even after inline keyword is used. Only small functions should be made inline. If the functions are bigger in size, then they should be declarations normal functions. Before calling an inline function, it is required that the function is defined elsewhere.