stack.cpp

来自「利用堆栈进行表达式的计算」· C++ 代码 · 共 47 行

CPP
47
字号
// Stack.cpp: implementation of the CStack class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Stack.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CStack::CStack()
{
	top = 0;
}

CStack::~CStack()
{

}

void CStack::push(CMyObject *E)
{
	data[top++] = E;
}

CMyObject *CStack::pop()
{
	if(top <= 0)
		return NULL;

	return data[--top];
}

CMyObject *CStack::getTop()
{
	if(top <= 0)
		return NULL;

	return data[top - 1];
}

int CStack::getLength()
{
	return top;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?