Hi all,
Got a quick question regarding iterators and subtracting offsets and I was wondering if you can help me out here. I had some code that was accessing a vector like such:
.. but wanted to change it so that it used iterators. The following compiles and runs okay - just wondering however if the subtraction of one to offset the iterator is correct:Code:for (int i = 0; i < m_linkArray.size() - 1; i++) { m_linkArray[i]->update(); }
Thanks!Code:std::vector <CLink *>::iterator itPos = m_linkArray.begin(); for (; itPos < m_linkArray.end() - 1; itPos++) { (*itPos)->update(); }



LinkBack URL
About LinkBacks



