title: How can I use arithmetic operators (+, * etc.) on custom classes in C++?
body: <p>Consider this code, where I define a class called <code>Thing</code>:</p>
  
  <pre><code> 1 class Thing{
   2     public:
   3         int things;
   4         int stuff;
   5 };
   6
   7 int main(){
   8     Thing foo, bar;
   9     foo + bar;
  10     return 0;
  11 }
  </code></pre>
  
  <p>This question concerns line <code>9</code>. Trying to apply the <code>+</code> operator between objects which aren't <code>int</code> or <code>float</code> etc. raises an error, as expected:</p>
  
  <p><code>no match for 'operator+' in 'foo + bar'</code></p>
  
  <p>So here's my question. What do I need to do to the definition of <code>Thing</code>  in order to make the operation <code>Thing + Thing = valid output</code>?</p>
  
  <p>For example, <code>foo + bar = foo.things + foo.stuff + bar.things + bar.stuff</code>.</p>