RayvenHawk 22 Junior Poster in Training

Not to be rude, but how on earth are you able to write the code you have and be able to understand what the purpose behind it is?

Besides that the commenting is meant for YOU to understand so that if you leave the code alone for a good while, when you come back to it, those comments will help jog your memory as to why they are there and doing what they do. It's always best to comment it yourself so that you can relate to it at a later date otherwise if your memory fails and you look at the comments someone else did you're going to be at a loss.

Nick Evan commented: yup +22
RayvenHawk 22 Junior Poster in Training

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??

mharie_chue commented: sir, how was the codes in reversing a word using stacks? +0