From 6702f01db1491111af51626e078e49887095ab14 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sun, 11 Sep 2022 19:49:57 +0200 Subject: [PATCH] make minivec objects streamable --- minivec.hh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/minivec.hh b/minivec.hh index 7579294..af68fa0 100644 --- a/minivec.hh +++ b/minivec.hh @@ -1,5 +1,6 @@ #pragma once #include +#include struct Point { @@ -10,6 +11,13 @@ struct Point double x, y, z; }; +inline std::ostream& operator<<(std::ostream& os, const Point& p) +{ + os << '(' << p.x << ", " << p.y << ", " << p.z <<')'; + return os; +} + + struct Vector { Vector() : x{0}, y{0}, z{0} {} @@ -39,4 +47,9 @@ struct Vector } }; +inline std::ostream& operator<<(std::ostream& os, const Vector& p) +{ + os << '(' << p.x << ", " << p.y << ", " << p.z <<')'; + return os; +}