AP Computer Science Workshop


AP Classes: apstack

 
Code Effect
apstack<char> s; constructs an empty stack of chars
s = otherstack; assignment works
 
s.top(); returns copy of top element
s.isEmpty(); returns true if s is empty, false otherwise
s.length(); returns number of elements in stack
 
s.push(item); pushes item onto the stack
s.pop(); pops top element off stack
s.pop(item); pops top element and returns it in item
 
s.makeEmpty(); makes stack empty

Previous slide Mark Stehlik, Carnegie Mellon University Next slide