#include <iostream>
#include <deque>
#include <string>
#include <iterator>
using namespace std;
template<class T, class D>
class Member
{
private:
T name;
D sal;
public:
Member(T t, D d) :name(t), sal(d){}
void print();
};
template<class T, class D>
void Member<T,D>::print(){
cout << name << " " << sal << endl;
}
int main(){
typedef Member<string, double> M;
deque<M> d;
d.push_back(M("Robert",6000));
d.push_back(M("Linda",7500));
deque<M>::iterator it = d.begin();
cout << "Enter deque:" << endl;
while (it != d.end()){
(it++)->print();
}
cout << endl;
cout << "Return from back()" << endl;
d.back().print();
return 0;
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步