I've finished writing the program for my class and everything actually does what it's suppose to (well 99% anyway).
I'm going to add snippets of the code that should help figure out the small glitch. What's happening is I can add x amount of elements to my stack and display them, but when they are displayed they are in reverse order instead of from bottom to top (the order they were input into the stack).
template<class Type>
Type mystack<Type>::top() const
{
assert(stackTop != 0);
return list[stackTop - 1];
}
the above is the command to display the elements
template<class Type>
void mystack<Type>::push(const Type& newItem)
{
if(!isFullStack())
{
list[stackTop] = newItem;
stackTop++;
}
else
cout <<"Cannot add to a full stack."<<endl;
}
the above is the code to push the new element into the stack
if (choice == 1)
{
do
{
cin >> num;
intStack.push(num);
j++;
}
while(j < amount);
workStack = intStack;
}
the above is the main function to call the push command. (int j is initialized to 0)
Any reason why my stack is displaying backwards??