c++ - Referring to the address of a collection element via iterators -
how can refer address of element in vector using iterators.
vector<record>::const_iterator iter = collectionvector.begin(); while(iter != collectionvector.end()) { //how can refer address of record here function(...); //accepts &record type }
you can use &(*iter)
address. here sample code:
std::vector<int> a; a.push_back(1); std::vector<int>::iterator iter = a.begin(); int *p = &(*iter) ; *p =10;
Comments
Post a Comment