#include "point_class.h" //default constructor point2D::point2D () : x_(0), y_(0) { ++count_; } // copy constructor point2D::point2D (const point2D &p) : x_(p.x_), y_(p.y_) { ++count_; } // assignment operator (chaining, self-assignment) point2D & point2D::operator= (const point2D &p) { // self-assignment check if (this != &p) { x_ = p.x_; y_ = p.y_; } // allows chaining return *this; } // destructor point2D::~point2D () { --count_; } // static member variable definition (and explicit initialization for readability) unsigned int point2D::count_ = 0; // friend operator definition ostream & operator<< (ostream & os, const point2D &p) { os << p.x_ << " " << p.y_; return os; }