谁能帮我写个双向栈(C++)

来源:百度知道 编辑:UC知道 时间:2024/05/18 03:49:14
代码要全,不要只写个方法
程序简单点,能实现基本的读入和输出就好了

#include<iostream>
#include<cstring>
using namespace std;

enum Error_code{success,overflow,underflow,error};

template<class Node_entry>
struct Node{
Node_entry entry;
Node<Node_entry> *next;
Node<Node_entry> *prior;

Node();
Node(Node_entry,Node<Node_entry>*link_prior=NULL,
Node<Node_entry>*link_next=NULL);
};

template<class List_entry>
class List{
public:
List();
~List();
int size()const;
bool empty()const;
void clear();
// void traverse(void(*visit)(List_entry&));
// Error_code push(List_entry &x); 增加push函数,方便将数据直接插入列表最后
Error_code retrieve(int position,List_entry&x)const;
Error_code replace(int position,const List_entry&x);
Error_code remove(int position,List_entry&x);
Error_code insert(int position,const List_entry&x);
protected:
Node<