Examination of the push member function reveals that whilst new nodes are created, memory allocation checked, the node prepended and the data values stored, the stack’s head pointer (to the top node of the stack) is never updated. Hence the stack’s pointer remains pointing to null as originally created. The new nodes are therefore not available to the stack class and thus no data can be popped.

Next: Modified Code