Inline Function:
Normally in our program, we define a function, at that time compiler makes a copy of that function's definition in memory. And when we call to that function, at that time compiler jumps to that copied definition and when function returns the execution resumes from the next line in the calling part. that means if we make a call to that functions for 3 times each time the copied block of function in the memory will be run by compiler. Conclusion is that there is only one copy of the function's definition in the memory and during each call the function the same copy is referred. Unfortunately execution of program will slow down by this process. Hence the solution is to avoid this slow down process and want execution of program faster we need to use Inline function.
Inline is one type of function whose code is copied in place of each function call. The inline describes that the compiler should insert the complete body of functions in every place where the function is used.
In Inline function, if the function is called 3 times then for 5 times the code of the function is copied to the calling function and no jump is made to the memory. this method is increase the performance. it is also increased memory size because of the copy made on each calling part. Let us understand with example. Note that Inline function is a request, it is not a command.
#include<iostream.h>
inline void fun(); <-------------------------- function declaration
void main()
{
cout<<"you are admin";
func(); <----------------------------- Function call
}
void fun() <----------------------------- Function definition
{
cout<<"you are into fun";
}
In this program, we should know that Inline function must be declared in declaration part.Process will be the same for declaration, definition and call ,but main thing is it improves the execution of programs and increases the memory size. we should know that Inline is one type of request not command.
Friend Function:
It is a function which is not a member function of the class ,but it can access the private and public members of the class. In many friend function one can declare a class as friend to another class. It is the special type of function which is denoted by a keyword friend. Take a look in example given below.
If we use the friend function, we need to know that,
--> Friend function is involve like normal function.
--> It should be declared with the keyword.
--> It can access the private member of the class.
Thank You
My next post will be on Constructors. Until then BYE BYE!!!
you can follow us here for other more and interesting updates:
Facebook: CLICK HERE!!!!!!!!!!
Twitter: @NewAgeInformers
Instagram: @new_age_informers_
Normally in our program, we define a function, at that time compiler makes a copy of that function's definition in memory. And when we call to that function, at that time compiler jumps to that copied definition and when function returns the execution resumes from the next line in the calling part. that means if we make a call to that functions for 3 times each time the copied block of function in the memory will be run by compiler. Conclusion is that there is only one copy of the function's definition in the memory and during each call the function the same copy is referred. Unfortunately execution of program will slow down by this process. Hence the solution is to avoid this slow down process and want execution of program faster we need to use Inline function.
Inline is one type of function whose code is copied in place of each function call. The inline describes that the compiler should insert the complete body of functions in every place where the function is used.
In Inline function, if the function is called 3 times then for 5 times the code of the function is copied to the calling function and no jump is made to the memory. this method is increase the performance. it is also increased memory size because of the copy made on each calling part. Let us understand with example. Note that Inline function is a request, it is not a command.
#include<iostream.h>
inline void fun(); <-------------------------- function declaration
void main()
{
cout<<"you are admin";
func(); <----------------------------- Function call
}
void fun() <----------------------------- Function definition
{
cout<<"you are into fun";
}
In this program, we should know that Inline function must be declared in declaration part.Process will be the same for declaration, definition and call ,but main thing is it improves the execution of programs and increases the memory size. we should know that Inline is one type of request not command.
Friend Function:
It is a function which is not a member function of the class ,but it can access the private and public members of the class. In many friend function one can declare a class as friend to another class. It is the special type of function which is denoted by a keyword friend. Take a look in example given below.
If we use the friend function, we need to know that,
--> Friend function is involve like normal function.
--> It should be declared with the keyword.
--> It can access the private member of the class.
Thank You
My next post will be on Constructors. Until then BYE BYE!!!
you can follow us here for other more and interesting updates:
Facebook: CLICK HERE!!!!!!!!!!
Twitter: @NewAgeInformers
Can we make friend function inline?
ReplyDeleteI am a Single full time dad on disability getting no help from their moms. It a struggle every day. My boys are 15 and 9 been doing this by myself for 8 years now it’s completely drained all my savings everything . These guys are the present day ROBIN HOOD. Im back on my feet again and my kids can have a better life all thanks to the blank card i acquired from skylink technology. Now i can withdraw up too 3000 per day Contact them as well on Mail: skylinktechnes@yahoo.com or whatsspp/telegram: +1(213)785-1553
ReplyDelete