I'm writing a geometry class Polygon which has a private field std::vector points where Point:
struct Point {
double x,y;
}
I need to construct a polygon with an unknown number of points using templates.
I've tried
template<Point &head, Point &...tail>
Polygon() {
this->points.push_back(head);
Polygon(tail...);
}
But when calling Polygon polygon = Polygon(Point(1, 4), Point(14.5, -15), Point(0, 0.0));, it fails with
error: no matching constructor for initialization of 'Polygon'
What's the problem and how to fix it? I'm using C++14
Aucun commentaire:
Enregistrer un commentaire