void StackType::Push(symbol newItem) { if(IsFull()) throw FullStack(); top++; items[top] = newItem; }
void StackType::Push(ItemType newItem) // Adds newItem to the top of the stack. // Stack is bounded by size of memory. // Pre: Stack has been initialized. // Post: If stack is full, FullStack exception is thrown; // else newItem is at the top of the stack. { if (IsFull()) throw FullStack(); else { NodeType* location; location = new NodeType; location->info = newItem; location->next = topPtr; topPtr = location; } }