Formatting and check not assigning to self in operator=

feature/19
Daniel Warner 2011-04-09 19:57:58 +01:00
parent f21109960d
commit 6824a51d70
2 changed files with 9 additions and 5 deletions

View File

@ -111,11 +111,15 @@ bool Julian::operator<=(const Julian &date) const {
* assignment * assignment
*/ */
Julian& Julian::operator=(const Julian& b) { Julian& Julian::operator=(const Julian& b) {
date_ = b.date_;
if (this != &b) {
date_ = b.date_;
}
return (*this); return (*this);
} }
Julian& Julian::operator=(const double b) { Julian& Julian::operator=(const double b) {
date_ = b; date_ = b;
return (*this); return (*this);
} }

View File

@ -24,10 +24,10 @@ public:
bool operator>=(const Julian &date) const; bool operator>=(const Julian &date) const;
bool operator<=(const Julian &date) const; bool operator<=(const Julian &date) const;
Julian& operator=(const Julian& b); Julian & operator=(const Julian& b);
Julian& operator=(const double b); Julian & operator=(const double b);
Julian operator+(const Timespan& b) const; Julian operator+(const Timespan& b) const;
Julian operator-(const Timespan& b) const; Julian operator-(const Timespan& b) const;
~Julian() { ~Julian() {
}; };