From 3ff24b3242946ca9897832aed87da598d925f1ec Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Thu, 24 Oct 2024 15:14:15 +0200 Subject: [PATCH] Add operator<< for Point class in ex03 --- ex03/Point.cpp | 11 +++++++++++ ex03/Point.h | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ex03/Point.cpp b/ex03/Point.cpp index e3e6c8c..e1d3e78 100644 --- a/ex03/Point.cpp +++ b/ex03/Point.cpp @@ -43,3 +43,14 @@ int Point::halfplane_sgn(Point a, Point b) const else return (0); } + +void Point::print(std::ostream &ostream) const +{ + ostream << '(' << x << ", " << y << ')'; +} + +std::ostream &operator<<(std::ostream &ostream, const Point &point) +{ + point.print(ostream); + return (ostream); +} diff --git a/ex03/Point.h b/ex03/Point.h index b6e9217..0118baa 100644 --- a/ex03/Point.h +++ b/ex03/Point.h @@ -17,9 +17,12 @@ class Point Point &operator=(const Point &other); - int halfplane_sgn(Point a, Point b) const; + int halfplane_sgn(Point a, Point b) const; + void print(std::ostream &ostream) const; }; +std::ostream &operator<<(std::ostream &ostream, const Point &num); + bool bsp(const Point a, const Point b, const Point c, const Point point); #endif // POINT_H -- 2.30.2