>Write on the blackboard 100 times: "An iterator is not a pointer."
MyObjectList::iterator it;
for (it = list.begin(); it != list.end(); ++it) {
// I used to be able to do this:
MyObject* p_obj = it;
Foo(p_obj);
// Or this
Foo(it);
}
But now the error I get is 'cannot convert parameter 1 from
'std::vector<_Ty>::iterator' to 'MyObject *'
In VC6 this worked because vector::iterator was a typedef for T*. In
later versions that changed. Both forms satisfy the requirements of the
standard.
Well, you have an iterator that refers to an object, and you need the
address of that object. So there are two steps: get a reference from
the iterator, and take its address.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)