Give point an ostream operator

This commit is contained in:
Danny Robson 2011-09-13 15:12:30 +10:00
parent 8c995c22ac
commit 24e94d27fc
2 changed files with 11 additions and 0 deletions

View File

@ -57,3 +57,10 @@ point::operator+= (const point &rhs) {
return *this; return *this;
} }
std::ostream&
operator<< (std::ostream &os, const point &p) {
os << "point(" << p.x << ", " << p.y << ", " << p.z << ")";
return os;
}

View File

@ -20,6 +20,8 @@
#ifndef __UTIL_POINT_HPP #ifndef __UTIL_POINT_HPP
#define __UTIL_POINT_HPP #define __UTIL_POINT_HPP
#include <iostream>
namespace util { namespace util {
/// A three dimensional position in space. /// A three dimensional position in space.
struct point { struct point {
@ -34,5 +36,7 @@ namespace util {
}; };
} }
std::ostream& operator<< (std::ostream&, const util::point&);
#endif // __UTIL_POINT_HPP #endif // __UTIL_POINT_HPP