vector erase

what will this code do?

1
2
3
4
5
6
7
8
9
10
  #include<iostream>
  #include<string>
  #include<vector>
  int main()
{
  vector<string> object;
  for(int count=0;true;count++)
  object.erase((object.begin())-count);
return 0;
}
Last edited on
refering to this:

http://www.cplusplus.com/reference/vector/vector/erase/

An invalid position or range causes undefined behavior


as soon as count > 0 the iterator is invalid
This code tries to abort the program.:)
Topic archived. No new replies allowed.