//******************************************************** // The following code example is taken from the book // C++17 - The Complete Guide // by Nicolai M. Josuttis (www.josuttis.com) // http://www.cppstd17.com // // The code is licensed under a // Creative Commons Attribution 4.0 International License // http://creativecommons.org/licenses/by/4.0/ //******************************************************** #ifndef POLYGON_HPP #define POLYGON_HPP #include "geoobj.hpp" #include #include #include class Polygon : public GeoObj { private: std::array points; int size; public: // constructor for list of Coord's Polygon (std::string n, std::initializer_list pl) : GeoObj{std::move(n)}, size{static_cast(pl.size())} { assert(pl.size() <= points.size()); int idx{0}; for (const auto& p : pl) { points[idx++] = p; } } virtual void move(Coord c) override { for (int i=0; i clone() const override { return std::make_unique(*this); } }; #endif