#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() { int m[] = {1, 2, 3, 4, 5, 6}; deque d1; deque d2(m, m + 6); deque d4 = d2; // 拷贝构造函数: deque(const deque &deq) print(d4); d1 = d2; // 赋值运算符: deque& operator=(const deque &deq) print(d1); print(d2); deque d3(10, 1); // 10 个 1 print(d3); cout << "d5.swap(d2):" << endl; deque d5; d5.swap(d2); print(d5); print(d2); return 0; }