C++ Programming - OOPS Concepts - Discussion

Discussion :: OOPS Concepts - General Questions (Q.No.43)

43. 

Which of the following statements regarding inline functions is correct?

[A]. It speeds up execution.
[B]. It slows down execution.
[C]. It increases the code size.
[D]. Both A and C.

Answer: Option D

Explanation:

No answer description available for this question.

Dheerah Sharma said: (Jul 21, 2012)  
How it increases the code size? for long code we can use function.

French said: (Jul 21, 2012)  
Let's have some points on Inline function :

Advantages :

1) It does not require function calling overhead.

2) It also save overhead of variables push/pop on the stack, while function calling.

3) It also save overhead of return call from a function.

Disadvantages :

1) May increase function size so that it may not fit on the cache, causing lots of cache miss.

2) After in-lining function if variables number which are going to use register increases than they may create overhead on register variable resource utilization.

3) It may cause compilation overhead as if some body changes code inside inline function than all calling location will also be compiled.

4) If used in header file, it will make your header file size large and may also make it unreadable.

5) If somebody used too many inline function resultant in a larger code size than it may cause thrashing in memory. More and more number of page fault bringing down your program performance.

6) Its not useful for embedded system where large binary size is not preferred at all due to memory size constraints.

Johan Braanen said: (Dec 13, 2012)  
"It speeds up execution. " Is not always correct.

If you have a very big function, and want to call it a million times, performance would degrade if the CPU would have to load the new instructions form memory instead of using the cache.

Manisha said: (Jun 2, 2013)  
Inline function is used only when our code is small.

When inline function is called, then the definition of called function is attached with the calling function.

It fast the execution speed, because our program run in sequence order. There is no jumps no branching.

So, definitely program's code size increases still, it fast the execution speed.

Kushal Tewatia said: (Sep 17, 2013)  
Why it is different from macro?

Renu said: (Oct 26, 2013)  
How it increase code size ?

Smriti said: (Aug 9, 2014)  
How does it increases the code size? someone please explain.

Ashish Harsora said: (Nov 23, 2014)  
Inline function increases speed of execution because it store memory location at the first time after that it calls the function many times without refer the memory location.

Vyshnavi said: (Jun 16, 2016)  
It speed's up the execution but how it increases the code size?

An inline function is a function which is expanded in a line when it is invoked.

Abi said: (Jul 28, 2016)  
Please give a example code which contains an inline function.

Jyoti said: (Aug 4, 2016)  
What is inline function?

Ayesha... said: (Nov 9, 2020)  
If we used too many inline function resultant in a larger code size than it may cause thrashing in memory. More and more number of page fault bringing down your program performance.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.