Switch to full style
For C/C++ coders discussions and solutions
Post a reply

What are Inline functions?

Wed Jul 04, 2007 12:38 am

What are Inline functions? How to define inline function and why ?
--------------------------------------


The Inline keyword helps in speeding up programs by making very small functions execute more efficiently. A compiler compiles a new copy of the function each time it is called. However when you declare a function as inline, when the compiler expands a function call, the function's code gets inserted into the caller's code stream.

Essentially compiler will cut and paste the inline function wherever it is called in your program at compile time. Inline functions save the step of retrieving the function, at the cost of a larger compiled program. The MAX function is a typical (and good) example of a good time to use inline

cpp code
inline int MAX(int x, int y)
{
return (x > y) ? x : y;
}




Post a reply
  Related Posts  to : What are Inline functions?
 inline style for link tag.     -  
 What are Virtual Functions?     -  
 Functions and References     -  
 PHP Array Functions     -  
 Calling Functions Dynamically     -  
 using of scanf and printf functions     -  
 Lets Learn C++----->(Lesson 5) Functions     -  
 program to run shell command line functions     -  
 character running automatically / jump /duck/ functions     -  

Topic Tags

C++ Basics