Even though the program runs correctly, there is a memory problem somewhere in the program and I can't figure out what I have done wrong. I have allocated new memory for my stack and I'm deleting it as well, but still there is a problem somewhere.
See the attachments.© BrainMass Inc. brainmass.com September 24, 2018, 1:31 pm ad1c9bdddf - https://brainmass.com/computer-science/cpp/cplusplus-stack-memory-problem-501997
The error produced by this program is a little misleading. Various compilers will print out different messages but they will all say something similar to "possible corrupted stack". The "stack" being mentioned in this error message is NOT the stack class that is being implemented by the program. Instead, it is the heap used for memory allocation.
The Stack class constructor is correctly allocating a chunk of memory as an array. The destructor is correctly deleting that same ...
This solution explains potential issues with an improperly-working stack template and proposes solutions for fixing those issues so that the programs will work properly.