stack.cpp

来自「基于专家系统应用的程序代码 使用vc编程,access为数据库的程序」· C++ 代码 · 共 72 行

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

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

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

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

CStack::CStack()
{
 header=NULL;
}


CStack::~CStack()
{

}

void CStack:: push(CString str)
{
  stackList* node=new stackList();
  node->next=header;
  node->strData=str;
  header=node;  
}

CString CStack::pop()
{
  stackList* tempNode;
  CString tempStr;
  if(!empty())
  {
	  tempNode=header;
      header=header->next;
      tempStr=tempNode->strData;
      delete tempNode;
      return tempStr;
  }
  else 
	  return "";
}

bool CStack::empty()
{
  if (NULL==header)
	  return true;
  else 
	  return false;
}

void CStack::destroyStack()
{
	stackList* tempNode;
	while (header!=NULL)
	{    
      tempNode=header;
      header=header->next;   
      delete tempNode;
	}
}

⌨️ 快捷键说明

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