?? stack.cpp
字號:
#include "Stack.h"
#include "assert.h"
template<class Type>
Stack<Type>::~Stack()
{
StackNode<Type>*p;
while(top != NULL)
{
p = top;
top = top->link;
delete p;
}
}
template<class Type>
void Stack<Type>::Push(const Type &item)
{
top = new StackNode<Type>(item,top);
}
template<class Type>
Type Stack<Type>::Pop()
{
// assert(!IsEmpty());
Type retvalue;
if(!IsEmpty())
{
StackNode<Type> *p = top;
retvalue = p->data;
top = top->link;
delete p;
return retvalue;
}
return NULL;
}
template<class Type>
Type Stack<Type>::GetTop()
{
assert(!IsEmpty());
return top->data;
}
template<class Type>
void Stack<Type>::PrintElem()
{
char temp[10];
int i = 0;
StackNode<Type> *p = top;
while(p != NULL)
{
temp[i++] = p->data;
p = p->link;
}
for(int j = i-1;j >= 0;j--)
cout << temp[j];
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -