2024年3月9日发(作者:)
{
Node *temp=new Node(e);
return temp;
}
};
MyListStack链栈
template
class MyListStack
{
public:
Node *base;
Node *top;
int index;
MyListStack() //初始化链表
{
base=new Node();
top=base;
index=0;
}
void push(element n) //push
{
Node *temp=new Node(n);
top->next=temp;
temp->pre=top;
top=temp;
index++;
}
void pop(element & out) //pop
{
out=top->ele;
top=top->pre;
delete top->next;
top->next=NULL;
index--;
}
发布评论