Define inline functions, C/C++ Programming

Assignment Help:

Inline Functions

Imagine a c program, which reads disk records having employee information. If this is a payroll application each employee record data is probably processed by a series of function calls. These function calls could be to print the entity data, to compute the salary, to compute the taxes to be withheld etc,. Every one of these calls inherently contains overhead that must be part of your overall program. In other words it takes code space and time to push actual arguments onto the stack, call the function, push some return value onto the stack and finally pop all of those values.

C++ gives the inline functions, a mechanism by which these explicit function calls can be avoided.

"An inline function by definition is a function whose code gets substituted in place of the actual call to that function."

Whenever the compiler encounters a call to that function it merely replaces it with the code itself thereby saving you all of the overhead.  Such a function can be either a member of a class or a global function. Inline functions work best when they are small, straightforward bodies of code that are not called from too many dissimilar places within your program. The time saved will enhance with the increase in number of calls.

Even if you request that the compiler make a function into an inline function, the compiler may or may not honour that request.  It depends on the code of the function.  For instance, the compiler will not inline any function that contains a loop, static data member, or aggregate initializer list.  If such cases case, a warning message will be issued.

The drawbacks with inline functions is that if the code itself ever needs to be modified, then all programs that use the these functions would then have to be recompiled.  Moreover, an inline function is a violation of implementation hiding.

 


Related Discussions:- Define inline functions

Define the return statement in computer programming, Define The Return Stat...

Define The Return Statement in Computer Programming? The return statement is used for two purposes once the return statement is executed the program control will be immediately

Bouncing Ball, Create an applet that bounces a blue ball inside an applet u...

Create an applet that bounces a blue ball inside an applet using Thread. The ball (diameter is 10) will start at position (0,0). When the ball hits the edge of the applet, the ba

What are the precautions with function overloading, Precautions with functi...

Precautions with function overloading Function overloading is a boon to designers, since dissimilar names for same functions need not be thought of, which often is a cumbersome

I want im messenger, I would like to get you to collaborate in my project. ...

I would like to get you to collaborate in my project. We want a C programmer to Develop applications for Windows, the first application may be an Instant messenger encrypted in a w

Queue, program to enter 5 values in queue and remove value one by one from ...

program to enter 5 values in queue and remove value one by one from queue.

factorial series, 1)      Factorial (for this question just provide an a...

1)      Factorial (for this question just provide an answer for each part)  1.1  Debug the following program to calculate N! #include using namespace std; main()

Describe what is actual arguments, Describe what is actual arguments? -...

Describe what is actual arguments? - When certain functions are created and used to perform an action on some provided values, some values are required to be passed to them. Th

Arrays, how to write the code for operation research

how to write the code for operation research

Enumeration types, Write a simple program in C++ to investigate the safety ...

Write a simple program in C++ to investigate the safety of its enumeration types. Include at least 10 different operations on enumeration types that are incorrect/unsafe things to

Class and object, how to write c++ code for financial system using class an...

how to write c++ code for financial system using class and object

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd