title: Operator overloading+ add two objects
body: <p>I'm trying to add two object that they are in the same class.</p>
  
  <p>In the private section of the class I have two <code>int</code> variables</p>
  
  <pre><code>class One {
  
  private:
  int num1, num2;
  public:
  
      One operator+=(const One&amp;); // - a member operator that adds another One object - to the current object and returns a copy of the current object
      friend bool operator==(const One&amp;, const One&amp;); // - a friend operator that compares two One class objects for equality
  };
  
   One operator+(const One&amp;, const One&amp;);// - a non-friend helper operator that adds One objects without changing their values and returns a copy of the resulting One 
  </code></pre>
  
  <p>I'm not sure I have a problem on the <code>opeartor+</code> I guess</p>
  
  <pre><code>One operator+(const One &amp;a, const One &amp;b){
  
  One c,d,r;
  
  c = a;
  d = b;
  
  r += b;
  r += a;
  
  return r;
  }
  </code></pre>
  
  <p>I think the above code is wrong, but I tried to use like b.num1 and I get compile error</p>
  
  <p><code>error: 'int One::num1' is private
  error: within this context</code></p>
  
  <p>and I can't use b->num1 as well because the above function is not in the member function section.</p>
  
  <pre><code>error: base operand of '-&gt;' has non-pointer type 'const One'
  </code></pre>
  
  <p>This is how it calls in <code>main</code></p>
  
  <p><code>Result = LeftObject + RightObject;</code></p>