I am writing a program to manipulate a stack containing integers using push, pop, print, etc. The only thing I have left is to write a function called copy. Here is what I've tried so far:
void Stack::Copy(Stack otherStack)
{
otherStack.top = top;
for (int ii = top-1; ii >= 0; ii--)
{
otherStack.Push(elements[ii]);
}
}
and this:
void Stack::Copy(Stack otherStack)
{
otherStack.top = top;
for (int ii = top-1; ii >= 0; ii--) {
otherStack.elements[ii] = elements[ii];
}
}
Any help would be appreciated!
thanks