CPP Programming
About Lesson

An inline function is a function that is expanded in line when it is invoked.  The compiler replaces the function call with function definition.  We have to prefix the word inline before the function definition to make it inline.  It should be defined before its call.

The functions are made inline when they are small enough to be defined in one or two lines.

//Example program for Inline Function
#include<iostream>
using namespace std;

inline float mul(float x, float y)
{
return (x*y);
}
inline double div(double p, double q)
{
return(p/q);
}

int main()
{
float a=12.345;
float b=9.82;
cout<<mul(a,b)<<"\n";
cout<<div(a,b)<<"\n";
return 0;
}

You cannot copy content of this page