Advertisement
Guest User

d_date.cpp

a guest
Feb 3rd, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include "d_date.h"
  2. #include <stdexcept>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. bool date::operator< (const date& date1) const {
  8. return (year < date1.year && month < date1.month && day < date1.day);
  9. }
  10.  
  11. bool date::operator> (const date& date1) const {
  12. return (year > date1.year && month > date1.month && day > date1.day);
  13. }
  14.  
  15. date date::operator++ (){
  16. date temp = *this;
  17. temp.incrementDate(1);
  18. return temp;
  19. }
  20.  
  21. ostream& operator<<(ostream& ostr, const date& date1){
  22. ostr << date1.getDay() << "/" << date1.getMonth() << "/" << date1.getYear() << " ";
  23. return ostr;
  24. }
  25.  
  26. //istream& operator>>(istream& istr, date& date1){
  27. istream& operator>>(istream& istr, date& date1){
  28. int d, m, y;
  29. char ch;
  30. istr >> d >> ch >> m >> ch >> y >> ch;
  31. date1.setDay(d);
  32. date1.setMonth(m);
  33. date1.setYear(y);
  34. return istr;
  35. }
  36.  
  37. bool operator== (const date& date1, const date& date2) {
  38. return (date2.getDay() == date1.getDay() && date2.getMonth() == date1.getMonth() && date2.getYear() == date1.getYear());
  39. }
  40.  
  41. bool operator!= (const date& date1, const date& date2){
  42. return !(date1 == date2);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement