AI Horizon: Intelligence and Reason in Computers
Introduction Home Essays Resources Contact Info
  Basic CS
General AI
Chess AI

  Source Code
AI Tips and Tricks

  Code Journal
Site Updates

An Affiliate of

Stack Source Code
(Up to Resources : Source Code Repository : Lists)

This source file is an implementation of the Stack class. The class is implemented with templates.

For the templated class, the elements must have the operators >, =, and < defined.

This class has one new function:

const Elem &Peek(int Depth) const;

Given a whole number Depth, Peek() returns the Stack element which is Depth levels from the top. This stack element cannot be modified.

There is a default size limit of 500 elements for the stack, but this can be overridden in the constructor call. Read the source code for more information.

Download the Source: stack.h

All content is written and published by the people at or affiliated with AI Horizon <>.
Send any comments and suggestions to

Please report any errors to