⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stack.cpp

📁 语法分析器,很好的,同学写的,认为不错 .
💻 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 + -