I have been running to this problem over and over and don't seem to find what should I do. I have two vectors:
1 2
vector<int> vb(5);
vector<int> a(20);
I am trying to compare both vectors and delete the elements from "a" if elements are common. but it gives me the error: "vector subscript out of range"
For your second one, vector::erase() invalidates iterators, so it1 will stop being valid when you delete one element. Furthermore, I'm pretty sure you're dereferencing those iterators wrong...
For your first one... I'm missing something obvious here, sorry. Silly day...