// 2D point - without const and reference args // #include #include using namespace std; class Point { private: double x, y; public: Point(double xx, double yy) { x = xx; y = yy; } void print(const char msg[]) { cout << msg << ": (" << x << "," << y << ")" << endl; } static double distance( Point p, Point q) { double dx = p.x - q.x, dy = p.y - q.y; return sqrt(dx*dx+dy*dy); } }; // 2D point example // #include // #include "Point.h" using namespace std; int main() { Point p(1,2); p.print("p"); Point q(3,4); q.print("q"); cout << "distance = " << Point::distance(p,q) << endl; }