title: Operator overloading of private inner members
body: <p>Is it possible to overload a private inner class member as a non-member? It seems to me the only way is to overload as a member.</p>
  
  <pre><code>class Foo
  {
  private:
      struct Bar
      {
          int a;
          char b;
  
          Bar&amp; operator+=(const Bar&amp; rhs)
          {
              a += rhs.a;
              return *this;
          }
  
          // Only possibility?
          inline Bar operator+(const Bar&amp; rhs)
          {
              Bar bar;
              bar.a = this-&gt;a + rhs.a;
              bar.b = this-&gt;b;
              return bar;
          }
      };
  
      // Cannot do this as takes implicit reference (to Foo?).
      inline Bar operator+(Bar lhs, const Bar&amp; rhs)
      {
          lhs += rhs;
          return lhs;
      }
  };
  
  // Cannot do this as Bar private.
  inline Foo::Bar operator+(Foo::Bar lhs, const Foo::Bar&amp; rhs)
  {
      lhs += rhs;
      return lhs;
  }
  </code></pre>
  
  <p>I guess I could just use the member overload, but I understand it's preferable to overload the <code>+</code> operator as a non-member, and I would like to separate the implementation.</p>