I have the following functions:
Triangle* operator=(Triangle& other) const
{
for (unsigned int i = 0; i < other.getNumOfPoints(); i++)
{
this->addPoint(other.getPoint(i));
}
color = other.color;
//type stays the same
return this;
}
Point* Polygon::getPoint(int index) const
{
return _points.at(index);
}
void Polygon::addPoint(Point* p) {
Point* newp = new Point; //create a copy of the original pt
newp->setX(p->getX());
newp->setY(p->getY());
_points.push_back(newp);
}
I am sure each understand what the objects mean, they are pretty straight forward. First method is located inside Triangle class which inherit from Polygon.
Problem is in the first method when I use
this->addPoint(other.getPoint(i));
Eclipse states its Invalid argument. Can I get an explanation of why is it error when getPoint returns Point pointer and AddPoint function requires a Point pointer?
Thanks in advance.