/* * IntCell.h * */ #ifndef INTCELL_H_ #define INTCELL_H_ class IntCell { public: // constructor IntCell(int initValue = 0) { value = new int(initValue); } // copy constructor IntCell(const IntCell & rhs) { int val = *rhs.value; // think about this line value = new int(val); } // destructor ~IntCell() { delete value; } // overloading the = operator for our class IntCell & operator=(const IntCell & rhs) { if(this != &rhs) { *value = *rhs.value; } return *this; } int getValue() const { return *value; } void setValue(int val) { *value = val; } private: int *value; }; #endif /* INTCELL_H_ */