I am going to quote from C++ primer plus. If someone can please explain in simpler terms that would be great
given
"
in mainCode:template <class Type> bool Stack<Type>::pop(Type & item) { if (top > 0) { item=items[--top]; return true; } else return false; }
Stack<char *> st;
char po[40];
First, the reference variable item has to refer to an Lvalue of some sort, not an array name. Second, the code assumes that you can assign to item. Even if item could refer to an array, you can't assign to an array name. So this approach fails, too.



LinkBack URL
About LinkBacks



op removes the top element and sets the Type &item to reference it. Method returns false if the top element does not exist, true otherwise.