title: How to compare two objects (the calling object and the parameter) in a class?
body: <p>I am writing a "Date" class for an assignment and I am having trouble doing one the of the functions. </p>
  
  <p>This is the header file for the class.</p>
  
  <pre><code>class Date
  {
  public:
  Date();                                  // Constructor without parameters
  Date(int m, int d, int y); // Constructor with parameters.
  
  // accessors
  int GetMonth();               // returns the size of the diamond
  int GetDay();
  int GetYear();
  
  // mutators
  bool Set(int m, int d, int y);
  bool SetFormat(char f);
  
  // standard input and output routines
  void Input();             
  void Show();              
  void Increment(int numDays = 1);                 
  int Compare(const Date&amp; d);     
  
  private:
  int month,                    // month variables
      day,                 // day variable
      year;               // year variable
  char format;
  };
  </code></pre>
  
  <p>The member function I am trying to make is the int Compare(const Date&amp; d) function. I need this function to compare two Date objects (the calling object and the
  parameter), and should return: -1 if the calling object comes first
  chronologically, 0 if the objects are the same date, and 1 if the parameter object
  comes first chronologically.</p>
  
  <p>I have tried doing a simple if statement with the == operator but I get errors. </p>
  
  <pre><code>  if (d1 == d2)
       cout &lt;&lt; "The dates are the same";
       return (0);
  </code></pre>
  
  <p>After the objects are created, the function should be called like this d1.Compare(d2)</p>
  
  <p>Thank you in advance!      </p>