Push and pop values and watch the C++ run one line at a time. The stack lives in a fixed array of 8 ints. topIndex marks the top (the head), and data[0] is always the bottom (the tail).
int data[8]main()Notice that pop() only moves topIndex down. The old value stays in the array until a later push writes over it.