Has the == operator been overloaded to work with the POINT struct?
I ask because I had thought it was, but I tried comparing a POINT with another a few minutes ago and I'm getting an error which seems to be saying it's not.
If it is, what is wrong with:
POINT p1;
p1.x = 10;
p1.y = 10;
POINT p2;
p2.x = 10;
p2.y = 10;
if (p1 == p2) { // do something }
And if it's not, may I offer the suggestion that it probably should be?
From what I know, POINT is just a standard windows C struct. No overloaded operators. If you really need it, try this:
bool operator == (POINT &p1, POINT &p2)
{
return (p1.x==p2.x) && (p1.y==p2.y);
}
Thanks for the reply, I wound up doing exactly that (geez, I think the code is identical to the letter!).
As per my original post, Johan, I offer this as a suggestion to add to the next release. I suspect comparing one POINT to another is a pretty common function, makes sense to be included I think.
POINT is a Windows C API struct.
fzammetti: I'll add it to the CPoint and CRect classes in 1.10...

Sounds good Johan

What is v1.1 though? Aren't we on 2.04?
I'm not sure it's a good idea to unconditionally overload op== for POINTs in a library. Maybe make it a conditional option via a macro flag? Even if it's on by default, it lets us disable it if we need to.
I've never been a fan of operator overloading myself, it's one of the lessons I think Java learned from C and didn't copy it. In this case it seems pretty natural though.
I personally feel an option to turn it on or off would just complicate matters, but let me offer an alternative:
Simply make it a method of the CRect and CPoint classes. Just like in Java when you have two string s1 and s2, you do
if (s1.equals(s2) {}
I think that would work just fine here as well.
Alternatively, or more likely in addition to that, have an overloaded version of the equals method that accepts two POINT structs (or RECT structs in the case of CRect) and compare them, so you could do things like:
POINT p1, POINT p2;
p1.x = 2; p1.y = 2;
p2.x = 5; p2.y = 5;
if (CPoint.equals(p1, p2) { }
Calling it 'equals' probably doesn't make sense, but I leave the exact verbage to Johan.
I think that might be cleaner and have the same basic effect.