It is not very easy with an array, and you probably need to store more data about the queue. E.g the members might be:
Code:
int* buffer; //the actual dynamic array
int* begin; //points to the head where popping occurs, initially == buffer
int* end; //points to the end where pushed values go, initially == buffer
int* max; //points to one-past-end of buffer, used to avoid going out of bounds
And then in pop and push you need to make sure that the following conditions are met:
Code:
void push(int n)
{
assert(end != max); //must have more room available
//...
}
int pop()
{
assert(begin != end); //must not be empty
//...
}
Of course, if you run out of room while pushing, asserting might not be the correct behaviour. Instead you should probably try to make more room, by copying things around to the beginning of the buffer if begin != buffer (i.e items have been popped and there's empty unused space), or by allocating a larger buffer if that is not possible.
In addition, your queue needs a copy constructor and an overloaded assignment operator (otherwise you'll leak memory/cause double deletes if a queue is copied/assigned).