Monday, April 5, 2021

inline function (pop) (26)

  /*inline function

                                     *****************/

/*inline function is a powerful concept in c++.it make the execution of program fast.for making 

a function inline we use the inline keyword before the function name. if a function is inline 

the compiler copy the code of a function and place at the place where the function calling.inline

function does not work in such circumtance. if a function contain a loop,static variable and 

recursive.if a function contain switch or goto statment.if function return type other then void.*/

#include<iostream>

using namespace std;

inline max(int a, int b)

{

return ((a>b)?a:b);

}

int main()

{

int x,y;

cout<<"please enter the value of x:";

cin>>x;

cout<<"please enter the value of y:";

cin>>y;

cout<<"maximum value is:"<<max(x,y)<<endl;

}

No comments:

Post a Comment