c++ inline function?

前端 未结 6 475
终归单人心
终归单人心 2020-11-27 12:49

Why should i do something like this:

inline double square (double x) { return x*x;}

instead of

double square (double x) {          


        
6条回答
  •  庸人自扰
    2020-11-27 13:17

    The inline function, if the compiler complies, will include the inline function in the code in which it was called as if no function was called (as though you had put the logic in the calling function) and avoid the function call overhead.

提交回复
热议问题