well, you're right, my Java example was more along the lines of how you can compare anything to null (except for the primitives). But here's another question which my resolve this issue altogether. Let's say I have this code (well nevermind, I do have this code...)
Code:
for (vector<Rectangle>::iterator itRect = it->getRectangles()->begin(); itRect != it->getRectangles()->end(); itRect++) {
// find the particular rectangle that we are in
if (itRect->isPointInRectangle(&downPoint)) {
itRect->setSelected(true);
itDownRectangle = itRect; // line x
selectionCount++;
break;
}
}
Now my original thinking which I would still like to accomplish somehow is:
The itDownRectangle in line x is decalred as:
Code:
static vector<Rectangle>::iterator itDownRectangle;
What I really wanted to do, but my lack of expertise in C++ prevented me from was:
Code:
static Rectangle * downRectangle;
and then
Code:
// new line x
downRectangle = itRect; // rather the pointer the itRect points to
I tried several variations of the above code but gave up, correct me if I'm wrong but this would make a copy instead of just another reference to the same object?
Code:
*downRectangle = *itRect;
I think I tried it like that originally but because it was a copy, it was kind of useless to me. Anything else I tried resulted in compiler errors so that was no good either. So forget about checking the iterator, how can I get a pointer to the object the iterator is currently pointing to? Then I should be able to compare to NULL right? That would be the ideal situation.
Thanks