如何用两个栈实现列表功能

img


对大一新生来说真的挺迷茫的 希望各位热心市民帮我改改代码!谢谢了
//write your code here
#include
#include
#include
using namespace std;
class Queue
{
public:
stack sk1;
stack sk2;
//判断队列是否为空,
bool empty() {
return sk1.empty();
}
//进队操作,将元素e进队作为队尾元素
void push(int e) {
while(!sk1.empty())
{
int a = sk1.top();
sk2.push( tmp );
sk1.pop();
}
sk2.push(e);
while(!sk2.empty())
{
int tmp = sk2.top();
sk1.push(tmp);
sk2.pop();
}
}
//出队操作,从队头出队一个元素
int pop()
{
int r = sk1.top();//将栈顶元素
sk1.pop();
return r;
}
bool gethead

};