Code /* MyObj.h CIS 250 David Klick 2009-02-23 Implementation of MyObj class for tlist class test. */ #ifndef __MYOBJ_H_ #define __MYOBJ_H_ #include using std::cout; using std::ostream; class MyObj { private: int num; public: MyObj(); MyObj(const int x); void print() const; int getNum() const; void setNum(const int x); bool equals(const MyObj* m) const; bool operator==(const MyObj& obj) const; friend ostream& operator<<(ostream& strm, const MyObj& obj); }; MyObj::MyObj() { setNum(0); } MyObj::MyObj(const int x) { setNum(x); } int MyObj::getNum() const { return num; } void MyObj::setNum(const int x) { num = x>=0 ? x : -x; } void MyObj::print() const { cout << num << " "; } bool MyObj::equals(const MyObj* m) const { return num == m->num; } bool MyObj::operator==(const MyObj& obj) const { return num == obj.num; } ostream& operator<<(ostream& strm, const MyObj& obj) { return strm << obj.num; } #endif