c++ inline functions -


i'm confused how inline functions in c++....

lets function. how turned 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, can use inline keyword tell compiler want function inlined. inline keyword compiler hint. compiler can , chose ignore request if wants or needs to.

an alternative make function function template, blown out inline:

template<class val> val maximum( val x, val y, val z ) {    val max = x;    if ( y > max )       max = y;    if ( z > max )       max = z;    return max; }    

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -