TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Saturday 30 May 2020

Inline In C++ | Inline In C++ Programming Language | Inline In C++ Language With Example | Inline In C++ Language In Hindi

Inline In C++


C++ has a different solution to this problem. To eliminate the time of calls to small functions, C++ proposes a new function called inline function. An inline function is a function that is expanded in line when it is invoked thus saving time. The compiler replaces the function call with the corresponding function code that reduces the overhead of function calls.

One of the major objectives of using functions in a program is to save memory space, which becomes appreciable when a function is likely to be called many times.

image of inline in c++
Fig: Inline In c++

Advantages of Inline function

  • Function call overhead doesn’t occur.
  • It saves the overhead of a return call from a function.
  • It saves the overhead of push/pop variables on the stack when the function is called.


Limitations of Inline functions

  • Large Inline functions cause Cache misses and affect efficiency negatively.
  • Compilation overhead of copying the function body everywhere in the code at the time of compilation which is negligible in the case of small programs, but it may make a big difference in large codebases.
  • If we require address of the function in a program, the compiler cannot perform inlining on such functions.


Syntax:

inline returntype functionname (argument list)

{

function of body;

}


Program:

#include<iostream.h>

#include<conio.h>

inline intmulti(int a, int b)

{

return(a*b);

}

void main()

{

int a,b,c;

cout<< “input two number”;

cin>>a>>b;

c=multi(a,b);

cout<<c;

getch();

}


Output:

Input two number:

45

35

1575


No comments:

Post a Comment