/* * Copyright 2011 Steven Gribble * * This file is the solution to an exercise problem posed during * one of the UW CSE 333 lectures (333exercises). * * 333exercises is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 333exercises is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with 333exercises. If not, see . */ #ifndef _EX_THREEDPOINT_H_ #define _EX_THREEDPOINT_H_ #include namespace threedp { class ThreeDPoint { public: // Default, zero-argument constructor with an initialization list. ThreeDPoint() : x_(0), y_(0), z_(0) { } // Three-argument constructor. ThreeDPoint(double x, double y, double z) : x_(x), y_(y), z_(z) { } // Copy constructor ThreeDPoint(const ThreeDPoint ©me) : x_(copyme.x_), y_(copyme.y_), z_(copyme.z_) { } // Accessors double get_x() const { return x_; } double get_y() const { return y_; } double get_z() const { return z_; } // Inner product double operator*(const ThreeDPoint &rhs); // Assignment operator ThreeDPoint &operator=(const ThreeDPoint &rhs); private: double x_, y_, z_; }; } // namespace threedp // Override "<<" for std::ostream std::ostream &operator<<(std::ostream &out, const threedp::ThreeDPoint &pt); #endif // _EX_THREEDPOINT_H_