Search code examples
c++inline-functions

Are member functions always inline, or is it just a hint?


If we define a member function inside the class definition itself, is it necessarily treated inline or is it just a request to the compiler which it can ignore.


Solution

  • Yes, functions that are defined inside a class body are implicitly inline.

    (As with other functions declared inline it doesn't mean that the complier has to perform inline expansion in places where the function is called, it just enables the permitted relaxations of the "one definition rule", combined with the requirement that a definition must be included in all translation units where the function is used.)