資源簡介
這個是用模板實現的棧,有利于學習模板,以及學習棧的知識。
代碼片段和文件信息
/*
????Discription:?To?implement?a?class?of?satck?with?many?operations
????Author:?Jiang?Liuyang
????Cridit:?2016202185
????Date:?2018/04/20
*/
#include?
#include?
#include?
#include?
#include?
using?namespace?std;
template??//?a?template?of?the?class?Stack
class?Stack?//?the?difination?of?the?class?Stack
{
private:
????T*?top;?//?a?pointer?point?to?the?first?position?of?the?array
????int?capacity;?//?the?maximal?number?the?stack?will?contain
????int?size;?//?the?number?of?stack?have?contained
public:
????Stack(int?tem_size)?//?initial?of?a?stack
????{
????????T*?p;
????????size?=?0;
????????capacity?=?tem_size;
????????//p?=?(int?*)malloc(sizeof(int)*capacity);
????????p?=?new?T?[capacity];
????????i
- 上一篇:MOPSO算法代碼
- 下一篇:OpenGL繪制長方體
評論
共有 條評論