What are 'inline' functions, and does the compiler always respect the inline keyword?

Last updated 21 June 2026

  • As an optimization, inline is only a hint to replace calls with the function body. The compiler may ignore it (large or recursive functions) or inline unmarked functions.

  • The guaranteed meaning is a linkage rule: it relaxes the one-definition rule so identical definitions can appear in multiple translation units, which is why inline functions live in headers.

  • Member functions defined inside a class body are implicitly inline. Over-inlining bloats code, so trust the optimizer and link-time optimization.

  • https://utkrusht.ai/blog/cplusplus-interview-questions
  • https://roadmap.sh/questions/cpp
  • https://internshala.com/blog/cpp-coding-interview-questions/
All C++ interview questions