previous | start | next

1.1.1 Example 1: Stack

We can use the Array class to create a Stack class.

template <typename T>
class Stack
{
private:
  Array<T> a; // Using the Array class
public:
  Stack();
  bool empty() const;
  void push(const T& x);
  T pop();
  T top() const;
};

This Stack class "has" an Array member.



previous | start | next