3第三讲——模板基础.pptVIP

  • 3
  • 0
  • 约8.66千字
  • 约 38页
  • 2017-06-17 发布于河南
  • 举报
3第三讲——模板基础

主要内容 1 模板的概念 2 函数模板 3 类模板 4 编程示例:栈模板 1. 模?板?的?概?念 2. 函 数 模 板 3. 类 模 板 4 编程示例: 栈模板 Thanks! public: bool IsEmpty( ) {return (height==0)?True:False;} virtual void push(T )=0; virtual void pop(T )=0; virtual void Empty( )=0; virtual void ReadTop(T )=0; }; //使用数组存储数据元素的栈类模板(又叫基于数组的栈) template class T, int Size //模板类派生出模板子类 class ArrayStack:public AbsStackT{ bool Error; T vec[Size]; public: ArrayStack( ){Empty( );} virtual void push(T ); virtual void pop(T ); virtual void Empty( ); virtual void ReadTop(T ); bool IsError( ){return Error;} }; //压栈操作 t

文档评论(0)

1亿VIP精品文档

相关文档