#include #include #include #include using namespace std; class FooT { public: bool operator == (const FooT & other) { return data == other.data; } bool operator < (const FooT & other) { return data < other.data; } int data; }; int main() { vector data; FooT foo; for(int i =0; i < 10; ++i) { foo.data = rand() %100; data.push_back(foo); } sort(data.begin(), data.end()); for(auto x =begin(data); x != end(data); ++x) { cout << x - begin(data) << " " << x->data << " " ; } cout << endl; auto y = data.begin() + 5; cout << "Erasing from " << y->data << " to " << (y+3) -> data << endl; y = data.erase(y, y+3); cout << "Now points to " << y->data << endl; cout << endl; for(auto x =begin(data); x != end(data); ++x) { cout << x - begin(data) << " " << x->data << " " ; } cout << endl; }