A stack is a LIFO queue (last-in-first-out) so there is no provision to access members of the stack or move them around.
That is done using a vector.
Thats kind of what I thought, but the homework question reads: part a
"Write a function - template <typename T>
-
T second(const stack<T>& s);
that uses stack operations to return the second element on the stack."
For this part I just popped to
T temp then used
top( ) then
push(temp) and I output the value that I got from
top( )
But for part b:
Write a function - template <typename T>
-
void n2top(stack<T>& s, int n);
that moves the nth element (counting from the top, which is element 1) of the stack to the top, leaving the order of all other elements unchanged.
So I'm still not really sure what its looking for.