MC logo
Point Class Implementation File II
[^] Code Examples
<<Point Class Header File II point4.cc Point Class User File II>>
// This is a implementation file for point4.h.  It contains
// the body of the only long-ish function.
#include "point4.h"
#include <math.h>

// Distance to another point.  Pythagorean thm.
double Point::dist(Point other) {
        double xd = xval - other.xval;
        double yd = yval - other.yval;
        return sqrt(xd*xd + yd*yd);

The :: notation is used here to denote a function which is a member of a class. If it were omitted, the compiler would think we were defining an ordinary top-level function named dist.
<<Point Class Header File II Point Class User File II>>