How to I implement an equality operator?

I also have a Point class with protected: x and y.

How do I implement an equality operator?

Kept getting the error:
no match for 'operator=='

1
2
3
4
5
vector<Point> p;

if (p.end() == find(p.begin(), p.end(), Point(x, y))) {
	p.push_back(Point(x, y))
} 


The first section here should help you:
http://cplusplus.com/doc/tutorial/classes2/
1
2
3
4
5
bool Point::operator==(Point& RightHandSide)
{
    return (this->x == RightHandSide.x && 
            this->y == RightHandSide.y);
}
Last edited on
Topic archived. No new replies allowed.