C++ : Inline Functions

Inline Functions

Whenever a function is normally called, an extra overhead related to going to the called functions and then returning back to the calling function is involved. This process is time consuming. If the function is called numbers of times then lot of time is wasted. And thus execution time of the program increases.(this process is known as function call implementation)

C++ provides a method to avoid this overhead by declaring the function as inline. When a function is declared as inline the whole function body is substituted at the place of function calling statement. No extra overhead is involved. And thus execution time of the program decreases (this process is known as function body substitution).

The function can be made inline by using the keyword “inline” while giving the definition of the function.

Example:
inline void student::read()
{
statements;
}

Number Of Visitors

0238224