why do we actually use "inline" in a function? what are the benefits of using it?
I believe it tells the compiler to place the function directly into the code that called it. That means that during runtime we don't need to store the address of that function and then call it, it's just all right there already.
It just copies the code in place of the function call as opposed to calling the function. Theres an article somewhere around here explaining the pros and cons, and when to inline and when to not inline
an inlined function will not be called by the calling code, instead compiler will replace the calling part with function it self.
marking the function as inline is the same as teling the comiler that this function should be a candidate for an inline function.

note that should be a candidate not must be inlined.

after that compiler will choose wether to inline it or not.
however visual studio has an compiler option which allows you to partialy control inlining.
the compiler option is called /Ob and can be found under:
project>property pages>C/C++>Optimization>inline function expansion

inline keywod is not used only for plain functions but also memberfunctions which allows you to define memberfunction outside a class, thus behaviour will be the same as if you would define it inside a class.
thx everyone !
When a function is inlined this may result in code running faster as execution won't branch to the inlined function, but as it's copied into the calling function if the inlined function is called several times in different places the size of program will increase, taking more memory when loaded.
closed account (zb0S216C)
You should note that marking the function with inline doesn't mean the compiler will in-line the function; that is, the compiler can ignore the inline keyword if it likes.

Yea it's more of a suggestion to the compiler. If the compiler deems that not inlining will be more efficient, then you can say bye to your inline
Topic archived. No new replies allowed.