You are given a simple dynamic array class; i.e. an array that can grow on demand.
When one has any data structure, one may want to enumerate all elements in it. The Enumeration
interface provides a generic way of doing that. It works for arrays, linked lists, hash tables, trees, and so on. For arrays, it is quite simple to implement.
Implement an inner class for the enumeration. What state do you need to remember in the inner class? What state can you access in the enclosing class?