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 June 4, 2020, 3:10 am ad1c9bdddf
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.