谁能解释一下这个top->link到底什么意思?
数据结构题,
困惑ing~~~
程序如下:
template <class T>
class Stack()
{
friend LinkedStack<T>;
private:
T data;
Stack<T> *link;
};
template <class T>
class LinkedStack()
{
public:
LinkedStack() {top=0};
~LinkedStack();
bool IsEmpty() const{return top==0;}
bool IsFull() const;
T top() const;
LinkedStack<T>& Add(const T& x);
LinkedStack<T>& Delete(T& x);
private:
Stack<T> *top;
};
template <class T>
LinkedStack<T>::~LinkedStack()
{
Stack<T> *next;
while (top){
next=top->link;//这里的top->link是什么意思?
delete top;
top=next;
}
}