Inline function is a function which is expanded
at a particular line when it is called.
All the member functions defined inside the class
definition are by default declared as Inline
To declare a function as inline, use the keyword inline before the function name.
It is used to increase the execution time of a
program.
Inline functions are used to improve performance
of the application.
If a function is declared as inline, the compiler places a copy of the code of that
function at each point where the function is called at compile time. Many inline functions can lead your program to
grow up in size so that only small functions are declared as inline.
Advantages
It makes the program faster.
Syntax
Inline return_type function_name()
{
//function body
}
Example:
#include<iostream.h>
#include<conio.h>
inline void display() //function definition
{
cout<<"Welcome to learningPoint92";
}
void main()
{
display(); // function Call
getch();
}
Output:
Welcome to learningPoint92
No comments:
Post a Comment