/************************************************************************ * * * File: point.h * * * * Author: Robb T. Koether * * * * Date: Oct 19, 1999 * * * * Purpose: This file contains the definition of the Point class * * and related operators * * * ************************************************************************/ #ifndef POINT_H #define POINT_H // Header files #include #include #include using namespace std; /************************************************************************ * * * Definition of the Point class * * * ************************************************************************/ class Point { // Public member functions public: // Constructors Point(); // Default constructor Point(double xval, double yval); // Construct point from 2 doubles Point(const Point& p); // Copy constructor // Destructor ~Point(); // Destructor // Assignment operator Point& operator=(const Point& p); // Assignment operator // Inspectors double GetX() const; // Return the x-coordinate double GetY() const; // Return the y-coordinate // Mutators void SetX(double xval); // Set the x-coordinate void SetY(double yval); // Set the y-coordinate // Facilitators void Input(istream& in); // Extract this pt from istream void Output(ostream& out) const; // Insert this pt into ostream bool Equal(const Point& p) const; // See if pt equals this pt Point Add(const Point& p) const; // Add pt to this pt Point Multiply(double s) const; // Multiply this pt by scalar // Other member functions double Distance(const Point& p) const; // Distance between points // Private data members private: double x; // x-coordinate of the point double y; // y-coordinate of the point }; /************************************************************************ * * * Operators * * * ************************************************************************/ // Input-Output Operators istream& operator>>(istream& in, Point& p); ostream& operator<<(ostream& out, const Point& p); // Equality Operators bool operator==(const Point& p, const Point& q); bool operator!=(const Point& p, const Point& q); // Arithmetic Operators Point operator+(const Point& p, const Point& q); Point operator*(double s, const Point& p); #endif