Inline function prototype vs regular declaration vs prototype

前端 未结 4 997
别那么骄傲
别那么骄傲 2020-12-21 09:02

What\'s the difference between inline function and then main like so:

inline double cube(double side)
{
   return side * side * side;
}

int main( )
{
    cu         


        
4条回答
  •  清歌不尽
    2020-12-21 09:33

    When you declare a function inline the compiler tries to speed up the code by more or less copying the body of the function to where it's called. It's only a suggestion and it's up the the compiler to make the decision on if it's possible.

    I'm not sure what would happen in the 3rd example. I imagine it would depend on the tool chain being used.

提交回复
热议问题