C++ Programming - OOPS Concepts - Discussion
Discussion Forum : OOPS Concepts - General Questions (Q.No. 43)
43.
Which of the following statements regarding inline functions is correct?
Discussion:
12 comments Page 1 of 2.
Manisha said:
1 decade ago
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.
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.
(1)
Ashish Harsora said:
1 decade ago
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.
(1)
Ayesha... said:
5 years ago
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.
(1)
Dheerah Sharma said:
1 decade ago
How it increases the code size? for long code we can use function.
French said:
1 decade ago
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.
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:
1 decade ago
"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.
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.
Kushal Tewatia said:
1 decade ago
Why it is different from macro?
Renu said:
1 decade ago
How it increase code size ?
Smriti said:
1 decade ago
How does it increases the code size? someone please explain.
Vyshnavi said:
9 years ago
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.
An inline function is a function which is expanded in a line when it is invoked.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers