title: C++ when to use an & in front of an operator overloading function
body: <p>When do you need to use an <code>&amp;</code> before the operator declaration?</p>
  
  <p>Example:</p>
  
  <pre><code>class ClassName {
       public:
          // Some constructor here..
  
          ClassName operator+(...)
          ClassName operator*(...)
          ClassName &amp;operator+=(...) &lt; has an &amp;
          ClassName operator==(...)
          ClassName &amp;operator&lt;&lt;(...) &lt; has an &amp;
       private:
          // Some member variables here..
  }
  </code></pre>
  
  <p>When you want to distinguish a postfix and prefix <code>i++</code> or <code>++i</code> you use an <code>&amp;</code></p>
  
  <pre><code>ClassName &amp;operator++()
  ClassName operator++(int)
  </code></pre>
  
  <p>But when do you use an <code>&amp;</code> for the other operator overload functions? Is there some kind of rule or has it something to do with the memory?</p>