顺序栈

#include<iostream>
using namespace std;
#define increasesize 10 template <class Object>
class Stack
{
public:
explicit Stack (int capacity = 10)
{
theArray = new Object[capacity];
MaxSize = capacity;
top = -1;
}
bool isEmpty() const
{
return top == -1;
}
bool isFull() const
{
return top == MaxSize -1;
}
const Object & Top() const
{
if(isEmpty()) throw Underflow();
return theArray[top];
}
void makeEmpty()
{
top = -1;
}
void Pop()
{
if(isEmpty()) throw Underflow();
cout<<theArray[top];
top -- ;
}
Object Push(const Object & x)
{
if(isFull())throw Overflow();
theArray [++top] = x;
}
Object topAndpop()
{
if(isEmpty()) throw Underflow();
}
int Underflow()
{
cout<<"underflow"<<endl;
return -1;
}
int Overflow()
{
cout << "overflow" <<endl;
return -1;
}
private:
int MaxSize;
int top;
Object * theArray;
};
int main()
{
Stack <int> dusk;
for(int i = 0 ; i < 10 ; i++)
{
dusk.Push(i);
}
for(int i = 0 ; i < 10 ; i++)
{
dusk.Pop();
}
} //template <class T>
//void dusk<T>::hanshu(T x)
//{}

  

最新文章

  1. java并发编程(九)死锁
  2. if 语句运用
  3. mysql 日期对比,varchar类型装换为datetime类型
  4. Linux永久修改系统时间和时区方法
  5. org.springframework.orm.hibernate3.support.OpenSessionInViewFilter作用
  6. Java自定义日志输出文件
  7. Hadoop中两表JOIN的处理方法
  8. [三]SpringMvc学习-封装、乱码问题、重定向、转发
  9. firefox-Developer开发者站点——关于Object.create()新方法的介绍
  10. java线程的等待、通知机制【读书笔记】
  11. mysql CMD命令
  12. c# winform多线程实时更新控件
  13. Python高级特性:切片
  14. CRM WEB UI 01 BOL向导创建的搜索
  15. MES制造执行系统
  16. Android开发-- 使用ADT23 的一些问题
  17. 用Nodejs连接MySQL(原文链接)
  18. ASCII码表(0-127 ) C中的转义字符
  19. JS字符串相关操作
  20. Metasploit域渗透测试全程实录(终结篇)

热门文章

  1. 深入理解webpack(二) webpack-dev-server基本配置
  2. Learn Python the hard way, ex41 来自Percal 25 号星星的哥顿人
  3. linux中cut命令
  4. 阻塞队列 BlockingQueue 常用方法详解
  5. c3p0连接池快速入门
  6. luogu_P1177 【模板】快速排序 (快排和找第k大的数)
  7. UDP千兆光通信(一)、整体认知与概述
  8. 给当当同学的random data
  9. Python实战之网上银行及购物商城
  10. python基础--6 集合