// deque 的删除操作 #include using namespace std; template void print(deque &dq) { typename deque::iterator it = dq.begin(); while (it != dq.end()) { cout << *it << " "; it++; } cout << endl; } int main() { string m[] = {"a", "b", "c", "d", "e"}; deque dq(m, m + 5); print(dq); deque::iterator del_it = dq.begin() + 1; // for (int i = 0; i < 3; i++) // { // // dq.erase() 会删除当前元素并返回下一个元素的迭代器 // del_it = dq.erase(del_it); // } // 第二种删除方式 dq.erase(del_it, del_it + 3); print(dq); return 0; }