Saturday, 6 July 2013

what is advantage of an inline function | what is an inline function | inline function

In case of an inline function the compiler takes decision whether to insert  the code or not depending upon the size of code and the compiler's optimizations settings. hence there is more likelyhood of  more optimized code getting generated.
In line function  provides better type checking and does not have side effects;

example :-
#include <iostream>

using namespace std; // this is namespace

inline float square(float y)
{
   
       return y*y;
}

int main()
{
     // calling 
            float x = square(7);

     

0 comments:

Post a Comment