How can I refer to the address of an element in a vect开发者_JS百科or using iterators.
vector<Record>::const_iterator iter = collectionVector.begin();
while(iter != collectionVector.end())
{
//How can I refer to the address of a Record here
function(...); //accepts &Record type
}
You can use the &(*iter)
to get the address. Here is a sample code:
std::vector<int> a;
a.push_back(1);
std::vector<int>::iterator iter = a.begin();
int *p = &(*iter) ;
*p =10;
精彩评论