What is C++ inline functions & when to use

admin Uncategorized

In C, we have used Macro function an optimized technique used by the compiler to reduce the execution time etc. So Question comes in mind that what’s there in C++ for that and in what all better ways? Inline function is introduced which is an optimization technique used by the compilers especially to reduce the execution time. We will cover “what, why, when & how” of inline functions.

What is inline function :
The inline functions are a C++ enhancement feature to increase the execution time of a program. Functions can be instructed to the compiler to make them inline so that the compiler can replace those function definitions wherever those are being called. The compiler replaces the definition of inline functions at compile time instead of referring function definition at runtime.
NOTE- This is just a suggestion to the compiler to make the function inline, if the function is big (in terms of executable instruction etc) then, the compiler can ignore the “inline” request and treat the function as a normal function.

How to make function inline:
To make any function as inline, start its definitions with the keyword “inline”.

 

 

 

 

 

 

 

For complete details visit my cplusplus article.

Leave a Reply

Your email address will not be published. Required fields are marked *