Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5. Functions > inline Functions

5.10. inline Functions

To avoid the overhead associated with a function call (i.e., creation of a stack frame containing copies of arguments or addresses of reference parameters and the return address), C++ permits you to declare functions to be inline. Such a declaration is a request to the compiler that it replace each call to the function with the fully expanded code of the function. For example:

inline int max(int a, int b){
  return a > b ? a : b ;
}

int main(){
   int temp = max(3,5);
    etc....
}


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial