Explore BrainMass

C++ stack, Memory Problem

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

I have created my stack template (not using stl). my methods work for the testing file.

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 October 25, 2018, 7:24 am ad1c9bdddf


Solution Preview

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 ...

Solution Summary

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.

See Also This Related BrainMass Solution

Introduction to Operating System Interfaces

Investigate the net for information about some of the new features offered by Vista over previous operating systems or operating systems on other computing environments. What makes Vista a better (or worse) choice for home or office computing?

View Full Posting Details