Stacks and QueuesThe data type stack (queue) can be used to store a number of objects of an arbitrary type T . The only element that can be accessed is the last (first) object added.ExampleThe following program shows how to use a stack. It generates astack S 
      of int and pushs the numbers 1 to 100 to S. Then it pops all elements 
      from the stack and outputs them. 
      
#include <LEDA/core/stack.h>
	
int main()
{
  leda::stack<int> S;
		
  int i;
  for (i=1; i<=100; i++) S.push(i);
		
  while (!S.empty()) {
    i=S.pop();
    std::cout << i << " ";
  }
  std::cout << std::endl;
		
  return 0;
}
      Strengths
 Disadvantages
 Tips
  | 
     
      See also:Manual Entries:  |