This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/ex7/stack.h
2021-11-11 20:45:47 +08:00

42 lines
694 B
C++

template <class T>
class Stack {
private:
T _v[10];
int _len=10;
int used=0;
public:
void push(T const&);
T pop();
T top() const;
bool empty() const;
protected:
// void expand()
// {
// _len = _len * 2;
// T *p = new T[_len];
// for (int i = 0; i <= _used; i++)
// p[i] = _v[i];
// delete[] _v;
// _v = p;
// }
// template <class T>
// void Vec<T>::shrink()
// {
// if (((double)_used / (double)_len) >= 0.25)
// return;
// _len = _len >> 1;
// T *p = new T[_len];
// for (int i = 0; i <= _used; i++)
// p[i] = _v[i];
// delete[] _v;
// _v = p;
// }
};