From: Jiri Vlasak Date: Wed, 14 Jul 2021 21:30:05 +0000 (+0200) Subject: Add operator<< for point X-Git-Tag: v0.6.0~10 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/bcar.git/commitdiff_plain/bc500bdea2c8ea222e91d57ff7c21003f3b3128c Add operator<< for point --- diff --git a/incl/bcar.hh b/incl/bcar.hh index 0615f53..5a4e466 100644 --- a/incl/bcar.hh +++ b/incl/bcar.hh @@ -57,6 +57,8 @@ public: * \param li The plane to consider is given by `li`. */ bool on_right_side_of(Line const& li) const; + + friend std::ostream& operator<<(std::ostream& out, Point const& p); }; class Line { diff --git a/src/bcar.cc b/src/bcar.cc index 4922132..985537e 100644 --- a/src/bcar.cc +++ b/src/bcar.cc @@ -95,6 +95,13 @@ Point::on_right_side_of(Line const& li) const } } +std::ostream& +operator<<(std::ostream& out, Point const& p) +{ + out << "[" << p.x() << "," << p.y() << "]"; + return out; +} + Line::Line(Point const& fp, Point const& lp): first(fp), last(lp), intersection1(Point(0.0, 0.0)), intersection2(Point(0.0, 0.0)) {