/**************************************************************************** * * * File: Point.h * * * * Author: Robb T. Koether * * * * Date: Oct 15, 2012 * * * * Purpose: This file contains the definition of the Point class and * * related operators * * * ****************************************************************************/ #ifndef POINT_H #define POINT_H // Header files #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 ~Point(); // 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 isEqual(const Point& p) const; // See if pt equals this pt Point add(const Point& p) const; // Add pt to this pt Point subtract(const Point& p) const; // Subtract pt from this pt Point multiply(double s) const; // Multiply this pt by scalar Point divide(double s) const; // Divide this pt by a 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-(const Point& p, const Point& q); Point operator*(double s, const Point& p); Point operator/(const Point& p, double s); #endif