title: Implementing small functions in a header file, including in two different files in the same project
body: <p>A quote from <a href="https://www.learncpp.com/cpp-tutorial/89-class-code-and-header-files/" rel="nofollow noreferrer">learncpp.com</a> about whether to ever implement functions in header files:</p>
  <blockquote>
  <ol>
  <li>For classes used in only one file that aren’t generally reusable, define them directly in the single .cpp file they’re used in.</li>
  <li>For classes used in multiple files, or intended for general reuse, define them in a .h file that has the same name as the class.</li>
  <li>Trivial member functions (trivial constructors or destructors, access functions, etc…) can be defined inside the class.</li>
  <li>Non-trivial member functions should be defined in a .cpp file that has the same name as the class.</li>
  </ol>
  </blockquote>
  <p>Suppose I follow the advice of #3, and I implement some small method <code>my_class::f</code> in the <code>my_class.h</code> file, but I leave the bigger methods to be implemented in <code>my_class.cpp</code>. If I include <code>my_class.h</code> in two different <code>.cpp</code> files in the same project, then the linker will see two (identical) definitions of <code>my_class::f</code>. (This is not solved by header guards.) I understand that some linkers are smart enough to tolerate this (though I've heard it can cost extra time). My question is:</p>
  <blockquote>
  <p>Do you think they recommend #3 because it is uncommon to include the same .h file twice across a project, or because the linker can be relied upon to ignore the duplicate definition, and will not waste too much time doing so?</p>
  </blockquote>