#include "C.h" //-- C::C(int v) : _v(v), _pv(new int) { *_pv = _v*2; } //-- C::C(const C& c) { _copy(c); } //-- C& C::operator=(const C& c) { if (this != &c) { _destroy(); _copy(c); } return *this; } //-- C::~C(void) { _destroy(); } //-- bool operator==(const C& c1, const C& c2) { if (c1._v != c2._v) return false; if (*c1._pv != *c2._pv) return false; return true; } //-- bool operator!=(const C& c1, const C& c2) { return !(c1==c2); } //-- ostream& operator<<(ostream& os, const C& c) { os << "(" << c._v << " " << *c._pv << ")"; return os; } //-- void C::_copy(const C& c) { _pv = new int; _v = c._v; *_pv = *c._pv; } //-- void C::_destroy(void) { if (_pv) delete _pv; }