template <class T, size_t N>

class ArrayStack

{

private:

size_t size = 0;

T data[N];

public:

bool isFull()

{

return size == N;

}

bool isEmpty()

{

return size == 0;

}

void push(T d)

{

if (isFull()) throw exception("stack is full");

data[size++] = d;

}

T top()

{

if (isEmpty()) throw exception("stack is empty");

return data[size - 1];

}

void pop()

{

if (isEmpty()) throw exception("stack is empty");

data[--size];

return

}

T peekAndPop()

{

if (isEmpty()) throw exception("stack is empty");

return data[--size];

}

ArrayStack() {}

~ArrayStack() {}


};


peekAndPop은 예제에서 쓸려고 만듬.