Griff Johns writes:
Correct.
Because an iterator is not a pointer. An iterator is an object of its own.
In most cases, the easiest thing to do would be "MyObject *p= &*it;".
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEABECAAYFAkj qgVsACgkQx9p3GY HlUOIEiACeI8sQ5 o/j2PF/kmGY7f/tU33D
erIAniaY62OoZTp BtHvA/xmqxg8jKkKj
=rfhH
-----END PGP SIGNATURE-----
>
MyObjectList::i terator 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<_T y>::iterator' to 'MyObject *'
>
This is after migrating a project from vc6.0 to vc7.1, but I think that
the issue lies with the language standards(?).
MyObjectList::i terator 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<_T y>::iterator' to 'MyObject *'
>
This is after migrating a project from vc6.0 to vc7.1, but I think that
the issue lies with the language standards(?).
So why does this happen
now,
now,
and how do I resolve it?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEABECAAYFAkj qgVsACgkQx9p3GY HlUOIEiACeI8sQ5 o/j2PF/kmGY7f/tU33D
erIAniaY62OoZTp BtHvA/xmqxg8jKkKj
=rfhH
-----END PGP SIGNATURE-----