代码清单3-10
class Queue
{
public:
Type MaxValue(Type x, Type y)
{
if(x > y)
return x;
else
return y;
}
Type Queue::Max()
{
return MaxValue(stackA.Max(), stackB.Max());
}
Insert2Queue(v)
{
stackB.push(v);
}
Type DeQueue()
{
if(stackA.empty())
{
while(!stackB.empty())
stackA.push(stackB.pop())
}
return stackA.pop();
}
private:
stack stackA;
stack stackB;
}