64,639
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
template<class T>
class MyQueue : public queue<T>
{
public:
void push(const value_type& x)
{
if(find(c.begin(), c.end(), x) == c.end())
{
//没找到此元素则添加
__super::push(x);
}
}
};
void main()
{
MyQueue<int> mq;
mq.push(1);
mq.push(1);
mq.push(1);
mq.push(2);
while(!mq.empty())
{
cout << mq.front() << "";
mq.pop();
}
}