From dd1a935ed4050e1f0540223c48e9d9de3e144bf3 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 13 Sep 2011 16:49:10 +1000 Subject: [PATCH] Add subtration operation for points --- point.cpp | 5 +++++ point.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/point.cpp b/point.cpp index d83c9e14..b302ab96 100644 --- a/point.cpp +++ b/point.cpp @@ -59,6 +59,11 @@ point::operator+= (const point &rhs) { } +point +point::operator- (const point &rhs) const + { return point (x - rhs.x, y - rhs.y); } + + std::ostream& operator<< (std::ostream &os, const point &p) { os << "point(" << p.x << ", " << p.y << ", " << p.z << ")"; diff --git a/point.hpp b/point.hpp index 67ea8b53..04ef61e7 100644 --- a/point.hpp +++ b/point.hpp @@ -33,6 +33,7 @@ namespace util { double manhattan (const point &) const; point& operator+= (const point&); + point operator- (const point&) const; }; }