home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 3 / RISC_DISC_3.iso / resources / etexts / gems / gemsv / ch7_4 / point.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-22  |  815 b   |  42 lines

  1. // -*- C++ -*-
  2. // point.h by George Vanecek Jr. June 1994
  3.  
  4. #ifndef _POINT_H_
  5. #define _POINT_H_
  6.  
  7. #ifndef _BASIC_H_
  8.   #include "basic.h"
  9. #endif
  10.  
  11. class Point
  12. {
  13. public:
  14.   Point ( const double x, const double y, const double z)
  15.     : _x(x), _y(y), _z(z) { }
  16.  
  17.   double x() const { return _x; }
  18.   double y() const { return _y; }
  19.   double z() const { return _z; }
  20.   Point&  operator +=( const Point& p);
  21.  
  22. protected:
  23.   double  _x, _y, _z;        // Point Coordinates
  24.   double& x() { return _x; }
  25.   double& y() { return _y; }
  26.   double& z() { return _z; }
  27. };
  28.  
  29. inline Point& Point::operator +=( const Point& p )
  30. { x() += p.x(), y() += p.y(), z() += p.z(); return *this; }
  31.  
  32. inline ostream& operator << ( ostream& outs, const Point& p )
  33. {
  34.   outs << '(' << p.x() << ' ' << p.y() << ' ' << p.z() << ')';
  35.   return outs;
  36. }
  37.      
  38.  
  39. #endif
  40.  
  41.  
  42.