title: Where would you use a friend function vs. a static member function?
body: <p>We make a non-member function a friend of a class when we want it to access that class's private members. This gives it the same access rights as a static member function would have. Both alternatives would give you a function that is not associated with any instance of that class.</p>
  
  <p>When must we use a friend function? When must we use a static function? If both are viable options to solve a problem, how do we weigh up their suitability? Is there one that should be preferred by default?</p>
  
  <p>For example, when implementing a factory that creates instances of class <code>foo</code> which only has a private constructor, should that factory function be a static member of <code>foo</code> (you would call <code>foo::create()</code>) or should it be a friend function (you would call <code>create_foo()</code>)?</p>