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

Popular posts from this blog

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -

jQuery clickable div with working mailto link inside -