[求助]数据结构问题
#include <iostream.h>
class stack;
class node
{
int data;
node *prev;
public:
node(int d,node *n)
{
data=d;
prev=n;
}
friend class stack;
};
class stack
{
node *top;
public:
stack()
{
top=0;
}
void push(int i)
{
node *n=new node(i,top);
top=n;
}
int pop()
{
node *t=top;
if(top)
{
top=top->prev;
int c=t->data;
//delete t;
return c;
}
return 0;
}
//friend class node;
};
void main()
{
stack s;
s.push(6);
s.push(3);
s.push(7);
s.push(1);
s.push(0);
s.push(2);
for(int i=0;i<6;i++)
cout<<s.pop()<<" ";
cout<<endl;
};
以上是个出椎的单向链表..
谁会数据结构?能帮我做个双向链表好吗?