Code #include using std::cout; using std::endl; class Point { private: int x, y; void init(const int x, const int y); public: Point(); Point(const int x, const int y); ~Point(); void setX(const int x); void setY(const int y); int getX() const; int getY() const; void print() const; }; Point::Point() { init(0, 1); cout << "In default constructor" << endl; } Point::Point(int x, int y) { init(x, y); cout << "In (int, int) constructor" << endl; } Point::~Point() { cout << "Destructing: "; print(); cout << endl; } void Point::init(const int x, const int y) { setX(x); setY(y); } void Point::setX(const int x) { // bounds checking only allows positive values this->x = x>=0 ? x : 0; } void Point::setY(const int y) { // bounds checking only allows positive values this->y = y>=0 ? y : 0; } int Point::getX() const { return x; } int Point::getY() const { return y; } void Point::print() const { cout << "(" << x << "," << y << ")"; } int main(void) { Point* ptr; Point p; cout << "Default point: "; p.print(); cout << endl; p.setX(8); p.setY(-7); cout << "After setting to (8,-7): "; p.print(); cout << endl; ptr = new Point(47, 2); cout << "New point: "; ptr->print(); cout << "\nx = " << ptr->getX() << ", " << "y = " << ptr->getY() << endl; delete ptr; return 0; } /* Sample output: In default constructor Default point: (0,1) After setting to (8,-7): (8,0) In (int, int) constructor New point: (47,2) x = 47, y = 2 Destructing: (47,2) Destructing: (8,0) */