mstack.cpp

来自「输入一个表达式子 然后输出 这个式子 的LL1文法形式」· C++ 代码 · 共 57 行

CPP
57
字号
// mstack.cpp: implementation of the Cmstack class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "LL1.h"
#include "mstack.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

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

Cmstack::Cmstack(TCHAR c)
{
	ch=c;
	next=NULL;
}

Cmstack::~Cmstack()
{

}

void Cmstack::push(Cmstack * & s,TCHAR c)
{
	Cmstack *temp=new Cmstack(c);
	if(s==NULL){
		s=temp;
	}else{
		temp->next=s;
		s=temp;
	}
}

void Cmstack::pop(Cmstack * & s)
{
	Cmstack *temp=s;
	if(temp!=NULL){
		s=s->next;
		delete temp;
	}
}

TCHAR Cmstack::get(Cmstack * & s)
{
	if(s!=NULL){
		return s->ch;
	}
	return _T('\0');
}

⌨️ 快捷键说明

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