To implement the Stack as a adapter class for array you should really start from the basic functionality of a stack. Let's consider a few basics:
constructor- created an empty stack
isFull/isEmpty - return true/false depending on how much space is available in your stack.
push - adds one element at the top of the queue
pop - removes the first element from the top of the queue
Let's start with the constructor: you could say that your stack is empty when top == -1. Since your array is statically allocated (you can consider to dynamically allocate memory for the array in the constructor), all you need to do is top =-1
and you have yourself an empty stack.
isFull/isEmpty now become obvious:
isEmpty:
return top == -1
isFull:
return top == MAX_SIZE
PUSH: adds one elements to the top of the stack:
if (!isFull)
{
top++;
A[top] = new_element;
}
I'll let you figure out the rest; the idea is to update the stack pointer top and always keep an eye on how much space you have available.