i’m confused about how to do inline functions in C++….
lets say this function. how would it be turned to an inline function
int maximum( int x, int y, int z )
{
int max = x;
if ( y > max )
max = y;
if ( z > max )
max = z;
return max;
}
As others have said, you can use the
inlinekeyword to tell the compiler you want your function inlined. But theinlinekeyword is just a compiler hint. The compiler can and will chose to ignore your request if it wants or needs to.An alternative is to make your function a function template, which will often be blown out inline: