topical media & game development

talk show tell print

professional-program-21-VectorIterators-IteratorSafety.c

? / professional-program-21-VectorIterators-IteratorSafety.c


  include <vector>
  using namespace std;
  
  int main(int argc, char** argv)
  {
    vector<int> intVector;
  
    vector<int>::iterator it = intVector.end();
    *it = 10; // BUG! it doesn't refer to a valid element
  
    vector<int> vectorOne(10);
    vector<int> vectorTwo(10);
  
    // fill in the vectors
  
    // BUG! infinite loop
    for (vector<int>::iterator it = vectorTwo.begin(); it != vectorOne.end();
         ++it) {
      // loop body
    }
  
    return (0);
  } 
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.