What is
difference between Friend function and Inline function ?
A friend function is used for accessing the non-public members of a class. A class can allow non-member functions and other classes to access its own private data, by making them friends. Thus, a friend function is an ordinary function or a member of another class.
Inline functions are functions where the call is made to inline functions. The actual code then gets placed in the calling program.
The inline function takes the format as a normal function but when it is compiled it is compiled as inline code. The function is placed separately as inline function, thus adding readability to the source program. When the program is compiled, the code present in function body is replaced in the place of function call.
Inline Function एक ऐसा Function होता है जिसे Call करने पर Program Control उस Called Function में नहीं जाता, बल्कि Program Control जहां पर होता है वहीं पर Inline Function Expand हो जाता है और Program अपने Normal Flow में Execute होता रहता है। Inline Function को Execute करने के लिए Program Control को Jumping में किसी प्रकार का समय Waste नहीं करना पडता hai
Example of inline function:-
#include<iostream.h>
Inline float add (float a, float b)
{
return(a+b);
}
int main()
{
float a=5.4
float b=7.4
Cout<<add(a,b)
return 0;
#include<iostream.h>
Inline float add (float a, float b)
{
return(a+b);
}
int main()
{
float a=5.4
float b=7.4
Cout<<add(a,b)
return 0;
Nice
ReplyDelete