------------------------------------------------------------------------------
MC logo
Point Class Impl File
[^] CSc 220 Home
------------------------------------------------------------------------------
[Introduction] [Boolean and Control] [Functions] [Arrays and Pointers] [Dynamic Arrays] [Array Errors] [Command Array] [Standard Containers] [Structs and Classes] [Automatic Pointer] [Multi-File Programs] [Copying Objects] [Templates] [Inheritance] [Plain C I/O] [Type Odds And Ends] [Plain C Strings] [File I/O]
[Point Hdr File] [Point Impl File] [Point User File] [Point Class Hdr File] [Point Class Impl File] [Point Class User File] [C++ Integer Stack ADT] [C++ Integer Stack Implementation] [C++ Integer Stack Driver]
point4.cc
// 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) const
{
        double xd = xval - other.xval;
        double yd = yval - other.yval;
        return sqrt(xd*xd + yd*yd);
}

// Print points using the << operator, so they can be printed along with
// other data types.
ostream & operator<<(ostream &strm, Point p)
{
        p.print(strm);
        return strm;
}