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;
}
The 3 program compile to exactly the same with
g++ -S -O3 $file.cc
. Except for the second example where the definition ofdouble cube(double side)
still exist in a non inlined form though inlined inint main()
.