title: error: expected primary-expression before '<<' token
body: <p>Okay so I'm building a Date class</p>
  
  <pre><code>class Date
  {
      private:
      int d;
      int m;
      int y;
  
   public:
      Date();
      Date(int&amp;, int&amp;, int&amp;);
      Date(const Date&amp;);
      bool isLeap();
      void setDay(int&amp; day)
      {d = day;}
      void setMonth(int&amp; month)
      {m = month;}
      void setYear(int&amp; year)
      {y = year;}
      int getDay() const
      {return d;}
      int getMonth() const
      {return m;}
      int getYear() const
      {return y;}
      void print(ofstream&amp; outfile)
      {
          outfile &lt;&lt; "The date in this class is: " &lt;&lt;  &lt;&lt; m &lt;&lt; "/" &lt;&lt; d &lt;&lt; "/" &lt;&lt; y;
      }
  
      Date operator= (const Date&amp;);
  };
  </code></pre>
  
  <p>I created an ofstream in main and opened the file. I'm also making sure to pass it by reference! Every time I try to compile I get the error: expected primary-expression before '&lt;&lt;' token message... Here is my main function. Let me know if I need anything else.</p>
  
  <pre><code>    int main()
  {
      int day;
      int month;
      int year;
      Date d1;
      ofstream outfile("Print.txt");
      int maxDays;
  
      Date d2 = d1;
  
      cout &lt;&lt; "Please enter the 4 digit year: ";
      cin &gt;&gt; year;
      if (year &gt; 0)
      {
          d1.setYear(year);
          cout &lt;&lt; "Please enter the 2 digit month: ";
          cin &gt;&gt; month;
          if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)
              maxDays = 31;
          else if (month==4||month==6||month==9||month==11)
              maxDays = 30;
          else if (month==2&amp;&amp;d1.isLeap()==false)
              maxDays = 28;
          else if (month==2&amp;&amp;d1.isLeap()==true)
              maxDays = 29;
          if (month &lt; 12)
          {
              d1.setMonth(month);
              cout &lt;&lt; "Please enter the 2 digit day: ";
              cin &gt;&gt; day;
              if (day &lt;= maxDays)
                  d1.setDay(day);
              else
              {
                  cout &lt;&lt; "Invalid input, will set to default." &lt;&lt; endl;
                  d1 = d2;
              }
  
  
          }
          else
          {
              cout &lt;&lt; "Invalid input, will set to default." &lt;&lt; endl;
              d1 = d2;
          }
      }
  
      else
      {
          cout &lt;&lt; "Invalid input, will set to default." &lt;&lt; endl;
          d1 = d2;
      }
  
      d1.print(outfile);
  
      if(d1.isLeap()==true)
          cout &lt;&lt; "This is a leap year\n";
      if(d1.isLeap()==false)
          cout &lt;&lt; "This is not a leap year\n";
  
      cout &lt;&lt; "The date is " &lt;&lt; d1.getDay() &lt;&lt; "/" &lt;&lt; d1.getMonth() &lt;&lt; "/" &lt;&lt; d1.getYear() &lt;&lt; endl;
  
      outfile.close();
  
      return 0;
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated...</p>