Inline
Inline
Inside the main() method, when the function fun1() is called, the control
is transferred to the definition of the called function. The addresses from
where the function is called and the definition of the function are different.
This control transfer takes a lot of time and increases the overhead.
When the inline function is encountered, then the definition of the function
is copied to it. In this case, there is no control transfer which saves a lot of
time and also decreases the overhead.
Once the compilation is done, the code would be like as shown as below:
1. #include<iostream>
2. using namespace std;
3. inline int add(int a, int b)
4. {
5. return(a+b);
6. }
7. int main()
8. {
9. cout<<"Addition of 'a' and 'b' is:"<<return(2+3);
10. return 0;
11. }