What are the advantages of inline function in c++

Post your questions, doubts and issues related to C/C++ Programming
no avatar
adams369
 
Posts: 13
Joined: Tue Dec 18, 2012 9:30 pm

What are the advantages of inline function in c++

by adams369 » Thu Jan 31, 2013 2:53 pm

Hi friends.
What are the advantages of using inline functions in C++.
Please give me brief description about inline functions in c++




Thanks & Regards
Adams
Uschemistoncall

no avatar
Twinkle
 
Posts: 2
Joined: Sun Jun 02, 2013 4:36 am

Re: What are the advantages of inline function in c++

by Twinkle » Sun Jun 02, 2013 5:01 am

Hey..


Inline functions are similar to macro. I hope you are familiar with macros :roll: .

In an inline function, the function body is placed on that specific position from where they have been called. However in case of a normal function, the control of the program is passed to the function body.

The major advantage here is that the inline functions are faster to implement. However you can not command the compiler to make your function inline. It will only do so if the function is appropriate. Functions with only one line body are suitable for making inline.

To declare a function inline, all you need to do is to mention the inline keyword before it.

no avatar
ballubhai
 
Posts: 1
Joined: Fri Jun 21, 2013 11:14 am

Re: What are the advantages of inline function in c++

by ballubhai » Fri Jun 21, 2013 11:48 am

:mrgreen: [quote] It is typically used for functions that execute frequently.

Return to C/C++ Programming

cron