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

C program for function of merge , C Program for FUNCTION OF MERGE #inc...

C Program for FUNCTION OF MERGE #include conio.h> #include stdio.h> char cot(char a[],char b[]); void main() {           char a[50],b[50];           clrscr()

There are ''''n'''' ants on a ''''n+1'''' leng n, There are ''''n'''' ants ...

There are ''''n'''' ants on a ''''n+1'''' length rod. The ants are numbered from 1 to n and are initially placed at positions starting from position 1 till position n. They are mov

Write a program to add co-ordinates of the plane, Write a program to add co...

Write a program to add co-ordinates of the plane The class having x and y co-ordinates. Create three objects. Use a constructor to pass one pair of co-ordinates and a funct

Stack and queues, Using Figure 10.2 as a model, illustrate the result of ea...

Using Figure 10.2 as a model, illustrate the result of each operation in the sequence ENQUEUE.Q; 4/, ENQUEUE.Q; 1/, ENQUEUE.Q; 3/, DEQUEUE.Q/, ENQUEUE.Q; 8/, and DEQUEUE.Q/ on an i

Equation, My project is compiling but the equation entered is not working

My project is compiling but the equation entered is not working

Define difference among delete and delete[]?, when you allocate memory with...

when you allocate memory with new[], you ought to free the memory via delete[]. While you allocate memory along 'new', then use 'delete' with no the brackets. You employ new[] to a

Asset pricing project, In the final project assignment you are asked to dev...

In the final project assignment you are asked to develop an OOP C++ class hierarchy for derivative pricing, using the binomial tree and Black-Scholes option pricing methods. You wi

C, how to learn programming skills

how to learn programming skills

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