title: Overloading the += operator
body: <p>I have the following code to overload the + and += operators respectively for the class Date. The operator + was successfully overloaded, and it will take an integer n and increase Date objects by n days. This is done by applying the next_day function n times.</p>
  
  <pre><code>inline Date operator+(Date d, int n)
  {
      for(char j=1; j&lt;=n; j++){
          d=d.next_day(d);
      }
      return d;
  }
  inline Date operator+=(Date d, int n)
  {
      Date p=d+n;
      return p;
  }
  </code></pre>
  
  <p>Having overloaded the + operator, I'm using it to define the overloading of += as well. But although no errors occurred in compilation, when I use the overloaded += it doesn't seem to have any effect.</p>
  
  <p>Here's my main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Date.h"
  using namespace std;
  
  int main() {
  
  Date Initialday = Date (12,1,2012);
  
  Initialday+=1;
  cout &lt;&lt;"Next day = "&lt;&lt; Initialday &lt;&lt;endl;
  
  return 0;
  }
  </code></pre>
  
  <p>Running the main function still gives me 12/1/2012 instead of 12/2/2012. What am I doing wrong? Note: I've already overloaded &lt;&lt; to output Date objects in a readable format, so I don't think that's the issue.</p>