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

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -