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

📄 lsmain.cpp

📁 经典c++程序的实现
💻 CPP
字号:
// lsmain.cpp

#include <stdio.h>
#include <assert.h>
#include <iostream.h>

#include "..\include\book.h"

typedef int ELEM;

#include "..\include\linkf.h"

// This creates space for the freelist variable
link* link::freelist = NULL;

void* link::operator new(size_t) { // Overload new operator
  if (freelist == NULL) return ::new link;  // Create new space
  link* temp = freelist;           // Otherwise, get from freelist
  freelist = freelist->next;
  return temp;                     // Return the link node
}

void link::operator delete(void* ptr) { // Overload delete operator
  ((link*)ptr)->next = freelist;        // Put on freelist
  freelist = (link*)ptr;
}

#include "..\include\lstack.h"

#include <stdio.h>
#include <assert.h>
#include <iostream.h>

#include "..\include\book.h"

typedef int ELEM;

main()
{
  Stack L1;
  Stack L2(15);

  L2.push(10);
  L2.push(20);
  L2.push(15);
  while(!L2.isEmpty()) {
    L1.push(L2.pop());
    cout << L1.topValue()<< " ";
  }
  cout << "\n";
  cout << "New top: " << L1.topValue() << "\n";
  L1.clear();
  cout << "That is all.\n";
  return(0);
}

⌨️ 快捷键说明

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