Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualFelix Ungman

Posted 22 May 2013 - 04:54 AM

What book is that? The "if (…) return true; else return false;" looks a bit, ehm, naive too...

 

I usually use something like the following pattern for less-than:

 

bool operator< (const Date& input) const
{
    int diff = year - input.year;
    if (diff == 0) diff = month - input.month;
    if (diff == 0) diff = day - input.day;
    return diff < 0;
}

#4Felix Ungman

Posted 22 May 2013 - 04:53 AM

What book is that? The "if (…) return true; else return false;" looks a bit, ehm, naive too...

 

I usually use something like the following pattern for less-than:

 

bool operator< (const Date& input) const
{
    int diff = year - input.year;
    if (diff == 0) diff = month - input.month;
    if (diff == 0) diff = day - day;
    return diff < 0;
}

#3Felix Ungman

Posted 22 May 2013 - 04:52 AM

What book is that? The "if (…) return true; else return false;" looks a bit, ehm, naive too...

 

I usually use something like the following pattern for less-than:

 

bool operator< (const Date& input)
{
    int diff = year - input.year;
    if (diff == 0) diff = month - input.month;
    if (diff == 0) diff = day - day;
    return diff < 0;
}

#2Felix Ungman

Posted 22 May 2013 - 04:51 AM

What book is that? The "if (…) return true; else return false;" looks a bit, ehm, naive too...

 

I usually use something like the following pattern for less-than:

 

bool operator< (const Date& input)
{
    int diff = year - input.year;
    if (diff == 0) diff = month - input.month;
    if (diff == 0) diff = day - day;
    return diff < 0;
}

#1Felix Ungman

Posted 22 May 2013 - 04:48 AM

What book is that? The "if (…) return true; else return false;" looks a bit, ehm, naive too...


PARTNERS