title: Free function versus member function
body: <p>What is the advantage of having a free function (in anonymous namespace and accessible only in a single source file) and sending all variables as parameters as opposed to having a private class member function free of any parameters and accessing member variables directly?</p>
  <p>header:</p>
  <pre><code> Class A {
      int myVariable;
      void DoSomething() {
         myVariable = 1;
      }
   };
  </code></pre>
  <p>source:</p>
  <pre><code> namespace {
      void DoSomething2(int &amp;a) {
          a = 1;
      }
   }
  
   int A::SomeFunction() {
      DoSomething2(myVariable); // calling free function
      DoSomething(); // calling member function
   }
  </code></pre>
  <p>If you prefer making them members, then what if I have a case where I first call a function that is not accessing any member variables, but that function calls another function which <em>is</em> accessing a member. Should they both be member functions or free?</p>