From 24e94d27fc910ff439e0ffc10c8d87196726c0f3 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 13 Sep 2011 15:12:30 +1000 Subject: [PATCH] Give point an ostream operator --- point.cpp | 7 +++++++ point.hpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/point.cpp b/point.cpp index ee144fce..d83c9e14 100644 --- a/point.cpp +++ b/point.cpp @@ -57,3 +57,10 @@ point::operator+= (const point &rhs) { return *this; } + + +std::ostream& +operator<< (std::ostream &os, const point &p) { + os << "point(" << p.x << ", " << p.y << ", " << p.z << ")"; + return os; +} diff --git a/point.hpp b/point.hpp index 1dcaee19..67ea8b53 100644 --- a/point.hpp +++ b/point.hpp @@ -20,6 +20,8 @@ #ifndef __UTIL_POINT_HPP #define __UTIL_POINT_HPP +#include + namespace util { /// A three dimensional position in space. struct point { @@ -34,5 +36,7 @@ namespace util { }; } +std::ostream& operator<< (std::ostream&, const util::point&); + #endif // __UTIL_POINT_HPP