03-C++ basic grammar (inline function inline function)

Using inline to modify the declaration or implementation of a function can make it an inline function

It is recommended to add inine modification to both declaration and implementation

Features:

  1.         The compiler will expand the function call directly into the function body code
  2.         Can reduce the overhead of function calls
  3.         Will increase code size

Notice:

  1.         Try not to inline functions longer than 10 lines of code
  2.         Even if some functions are declared inline, they may not be inlined by the compiler, such as recursive functions

When to use inline functions?

  1.         Function code size is small
  2.         frequently called functions

Inline functions and macros:

  1.         Both inline functions and macros can reduce the overhead of function calls
  2.         Compared with macros, inline functions have more syntax detection and function features

Guess you like

Origin blog.csdn.net/qq_56728342/article/details/129541270