M
mimi
It seems that iterator could be treated as the pointer to object. But
I am quite doubt about it.
Is using &(*iterator) instead of the pointer to object(after copy the
object from the iterator) permitted, or appreciated?
#include <vector>
int main()
{
std::vector<int> vecFoo(4, 0);
std::vector<int>::iterater iter = vecFoo.begin();
//Some function need a pointer to int, should i use
someFunc( &(*iter)); //(1)
//Should i use the following to replace the (1)
int i = *iter;
someFunc(&i);
return 0;
}
Thanks for any advice.
I am quite doubt about it.
Is using &(*iterator) instead of the pointer to object(after copy the
object from the iterator) permitted, or appreciated?
#include <vector>
int main()
{
std::vector<int> vecFoo(4, 0);
std::vector<int>::iterater iter = vecFoo.begin();
//Some function need a pointer to int, should i use
someFunc( &(*iter)); //(1)
//Should i use the following to replace the (1)
int i = *iter;
someFunc(&i);
return 0;
}
Thanks for any advice.