#include #include using namespace std; class Person { friend void print(deque &dq); private: string name; int age; public: Person(string name, int age) : name(name), age(age) {} }; void print(deque &dq) { deque::iterator it = dq.begin(); while (it != dq.end()) { cout << (*it).name << ", " << (*it).age << endl; ; it++; } } int main() { deque dq; dq.push_front(Person("张三", 18)); dq.push_back(Person("李四", 19)); dq.push_front(Person("王五", 20)); print(dq); cout << "--------" << endl; dq.pop_back(); dq.pop_front(); print(dq); return 0; }