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

Assignment, I have an assignment , can I send it

I have an assignment , can I send it

Define the logical operators in c language, Define the Logical Operators in...

Define the Logical Operators in c language? The Logical operators deals with the ways the relationships are able to connected. C has the following three logical operators

How can dereferencing the pointer this, Dereferencing the Pointer this ...

Dereferencing the Pointer this Sometimes a member function requires to make a copy of the invoking instance so that it can change the copy without affecting the original instan

Padovan string , .write a program that counts the number of occurrences of ...

.write a program that counts the number of occurrences of the string in the n-th padovan string p(n)   program in java // aakash , suraj , prem sasi kumar kamaraj college

Oop, what is oop?

what is oop?

Define nested class? why can it be useful?, it is a class enclosed in the s...

it is a class enclosed in the scope of another class. For illustration: // Example: Nested class // class OuterClass { class NestedClass { // ... }; // .

Program to make another type of mask, Write a function that has int paramet...

Write a function that has int parameter n, makes another type of mask having n bit 1's from the left most bit and 32- n bit 0's next. The mask is called netmask in this seminar, an

Jewel polishing, Byteland county is very famous for luminous jewels. Lumino...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

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