What's the difference between inline function and then main like so:
inline double cube(double side)
{
return side * side * side;
}
int main( )
{
cube(5);
}
vs just declaring a function regularly like:
double cube(double side)
{
return side * side * side;
}
int main( )
{
cube(5);
}
vs function prototype?
double cube(double);
int main( )
{
cube(5);
}
double cube(double side)
{
return side * side * side;
}
Performance wise, they are all the same since
inlineis just a hint for the compiler. If the separation of declaration/definition is used and the definition is on a different translation unit, then it will be harder for the compiler to inline it (but there are implementations that do so).A difference with making a function
inlineor not is that the linker will not complain if it sees the same inline definition for a function more than once.