c++ inline function?

前端 未结 6 489
终归单人心
终归单人心 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:15

    From Wikipedia: Inline function is a function upon which the compiler has been requested to perform inline expansion. In other words, the programmer has requested that the compiler insert the complete body of the function in every place that the function is called, rather than generating code to call the function in the one place it is defined. Compilers are not obligated to respect this request.

    http://en.wikipedia.org/wiki/Inline_function

提交回复
热议问题