大限将至,咸鱼的我决定开始极限复习数据结构,零零散散记一些笔记吧。
基础概念
栈类的定义
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| const int MAX_SIZE=100; class Stack { private: char *data; int size; int top; public: Stack(); Stack(int s); ~Stack(); void push(char ch); char pop(); char getTop(); bool isEmpty(); bool isFull(); void setNull(); }; Stack::Stack(){ size = MAX_SIZE; top = -1; data = new char[MAX_SIZE]; } Stack::Stack(int s){ size = s; top = -1; data = new char[size]; } Stack::~Stack(){ delete [] data; }
|