#include #include namespace co{ // Class for 3D coordinates class Point{ public: double x,y,z; }; double distance(const Point &, const Point &); } int main() { co::Point point1 = {0.0,0.0,0.0}, point2={1.0,2.0,1.0}; // move point1 a bit point1.x = 1.0; // public data member accessed directly std::cout<<"distance = "<< co::distance(point1, point2) <<"\n"; } // Euclidian distance between two points double co::distance(const co::Point &c1, const co::Point &c2){ return ( sqrt(pow(c1.x-c2.x,2) + pow(c1.y-c2.y,2) + pow(c1.z-c2.z,2) ) ); }