Created
April 11, 2010 05:10
-
-
Save zachelko/362514 to your computer and use it in GitHub Desktop.
STL begin() 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<int> foo; | |
// Add an item before setting the iterator... | |
// Should work, right? | |
foo.push_back(2); | |
std::vector<int>::iterator iter = foo.begin(); | |
// Add another item | |
foo.push_back(3); | |
// Use the iterator... oops! | |
while (iter != foo.end()) { | |
std::cerr << *iter << "\n"; | |
++iter; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment