title: c++ if statement not working in overloaded "++" postfix operator
body: <p>I'm trying to have the overloaded postfix operator make day = 1 whenever its day 365 the first snipped is me creating the prototype, and the second snippet is the actual code definition, i can't seem to figure this out. Any help would be appreciated.
  basically the program asks the user what day of the year do they want the date for.</p>
  
  <p>so the day could be 364 which would be December 30. </p>
  
  <p>I want the ++ operator to bring the day back to day 1 whenever I use it to increment objects that's day is 365. If the object isn't 365 I just want it to increment by 1 day</p>
  
  <p>whenever I change it to if(day == 365)
   it does the same thing, it still increments by one, but I end up with 366, not 1.</p>
  
  <p>I appreciate the help. It's a homework assignment, but it has me stomped. 
  EDIT : Posted more code. Thanks again for the help guys</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  
  using namespace std;
  
  class DayOfYear {            
      public:
          DayOfYear(int d);
          void print();
          static string month;
          DayOfYear();
          DayOfYear(string m, int d);
          DayOfYear operator++(int);
          int day;    
  };
  
  string DayOfYear::month;
  
  DayOfYear DayOfYear::operator++(int) {
      DayOfYear temp = *this;    
  
      if (day == 365) {
          day = 1;
      } else {
          day++;
      }
  
      return temp;
  }
  
  DayOfYear::DayOfYear(string m, int d) {
      month = m;
      day = d;
  
      if (m == "January" &amp;&amp; d &gt; 31) {
          cout &lt;&lt; "ERROR: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "February" &amp;&amp; d &gt; 28) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "March" &amp;&amp; d &gt; 31) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "April" &amp;&amp; d &gt; 30) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "May" &amp;&amp; d &gt; 31) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "June" &amp;&amp; d &gt; 30) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "July" &amp;&amp; d &gt; 31) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "August" &amp;&amp; d &gt; 31) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "September" &amp;&amp; d &gt; 30) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "October" &amp;&amp; d &gt; 31) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "November" &amp;&amp; d &gt; 30) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      } else if (m == "December" &amp;&amp; d &gt; 31) {
          cout &lt;&lt; "ERROR INVALID DATE: PROGRAM TERMINATING!" &lt;&lt; endl;
          system("pause");
          exit(0);
      }
  
      cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day &lt;&lt; endl; 
  }
  
  DayOfYear::DayOfYear() {
      cout &lt;&lt; "Enter a day number." &lt;&lt; endl;
      cin &gt;&gt; day;
      print();
  }
  
  DayOfYear::DayOfYear(int d) {
      day = d;
  
      while (d &gt; 365 || d &lt; 1) {
          cout &lt;&lt; "Day can't be higher than 365 and must be at least one. " &lt;&lt; endl;
          cin &gt;&gt; d; 
          day = d; 
      }
  
      print();
  }
  
  void DayOfYear::print() {
      if (day &gt; 0 &amp;&amp; day &lt; 32) //jan 31 
      {
          month = "January";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; 31 + day - 31 &lt;&lt; endl;
      }
      else if (day &gt; 31 &amp;&amp; day &lt; 60) // feb 28
      {
          month = "February";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 31  &lt;&lt; endl;
      }
      else if (day &gt; 59 &amp;&amp; day &lt; 91) // march 31
      {
          month = "March";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 59 &lt;&lt; endl;
      }
      else if (day &gt; 90 &amp;&amp; day &lt; 121) // april 30 
      {
          month = "April";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 90 &lt;&lt; endl;
      }
      else if (day &gt; 120 &amp;&amp; day &lt; 152) //may 31
      {
          month = "May";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 120 &lt;&lt; endl;
      }
      else if (day &gt; 151 &amp;&amp; day &lt; 182) //june 30
      {
          month = "June";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 151 &lt;&lt; endl;
      }
      else if (day &gt; 181 &amp;&amp; day &lt; 213) //july 31
      {
          month = "July";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 181 &lt;&lt; endl;
      }
      else if (day &gt; 212 &amp;&amp; day &lt; 244) // august 31
      {
          month = "August";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 212 &lt;&lt; endl;
      }
      else if (day &gt; 243 &amp;&amp; day &lt; 274) // sept 30
      {
          month = "September";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 243 &lt;&lt; endl;
      }
      else if (day &gt; 273 &amp;&amp; day &lt; 305) // oct 31
      {
          month = "October";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 273 &lt;&lt; endl;
      }
      else if (day &gt; 304 &amp;&amp; day &lt; 335) // nov 30
      {
          month = "November";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 304  &lt;&lt; endl;
      }
      else if (day &gt; 334 &amp;&amp; day &lt; 366) //dec 31
      {
          month = "December";
          cout &lt;&lt; month &lt;&lt; " " &lt;&lt; day - 334 &lt;&lt; endl;
      }
  }
  
  
  int main() {
      DayOfYear day;
  
      cout &lt;&lt; day.day &lt;&lt; endl; 
      cout &lt;&lt; day.day ++ &lt;&lt; endl;
      cout &lt;&lt; day.day &lt;&lt; endl;
  
      system("pause"); 
      return 0;
  }
  </code></pre>