+ 1
Cpp confusion
Can you guys elaborate me the non inline program and inline program. And what are the differences between these
1 Answer
+ 1
If you taking inline functions, I can talk about it. An inline function places code in each of the places they are called to perform the work. A non-inline function has code to make the call in each place they are called plus the shared function code to setup the function and the code to perform the work.
Depending on the number of times the function is called and the amount of code required to perform the work, one version will required less instructions. 40 years ago, coding the version that required less instructions was important as memory was very limited. Today, it really doesn't matter as the speed and memory different won't be noticed.
In general, a function called once will save as an inline. A couple of statements in a function called a couple of times will save as an inline. A huge function called many times will save as a regular function.