title: Where should I implement this "private" helper function?
body: <p>My class definition is spread across headers and source files:</p>
  
  <pre><code>// T.hpp
  
  class T {
     public:
        void foo();
  };
  
  // T.cpp
  
  void T::foo() {
  
  }
  </code></pre>
  
  <p>If <code>T::foo</code> needs to make use of some helper function that need be visible <em>only to <code>T</code></em>, which of the below solutions is best?</p>
  
  <h3>1. Private member</h3>
  
  <pre><code>// T.hpp
  
  class T {
     public:
        void foo();
     private:
        void helper();
  };
  
  // T.cpp
  
  void T::foo() {
      helper();
  }
  
  void T::helper() {
  }
  </code></pre>
  
  <h3>2. Free function accessible only in class definition's TU</h3>
  
  <pre><code>// T.hpp
  
  class T {
     public:
        void foo();
  };
  
  // T.cpp
  
  namespace {
      void helper() {}
  }
  
  void T::foo() {
      helper();
  }
  </code></pre>
  
  <p>Is there any difference except that with the former I will end up with more functions in the header file?</p>