The stack

Jul 19, 2011 at 4:50pm
Hi, I'm new to these forums!
I need help understanding "The Stack"
I understand its like a series of cubbyholes where 1 in is the first out
[]
[]
[]
[]
[]
but I don't understand whats the advantage of using the stack in c++ or why it was decided to be used, I don't get why you even need to understand it to code, any tips or questions to better understand it?
Jul 19, 2011 at 4:57pm
The first computers and hence assembler language took great advantage in using stacks because it makes quick access to programming steps and to local variables. Not just in C++, but C, VB, any language comes down to using stacks: The primary reason is that hardware is much easier to construct if it uses a stack.

Stacks are useful data structures as well. To be the best debugger, you need to embrace stacks IMHO.

Good luck!

Jul 19, 2011 at 5:04pm
i understand its useful, but where exactly are you going to include your knowledge about "The Stack" in your coding?
Jul 19, 2011 at 8:14pm
Perhaps if you were writing a calculator program, you would use a stack. See this link for more info: http://en.wikipedia.org/wiki/Stack_(data_structure). And this link: http://msdn.microsoft.com/en-us/library/aa227588(v=vs.60).aspx
Last edited on Jul 19, 2011 at 8:18pm
Jul 19, 2011 at 8:38pm
kooth,
thank you! the microsoft link gave me the answers i needed :)
Jul 19, 2011 at 8:40pm
That explains 'a stack', he is asking about knowing 'the stack'.

For general application level programming, you wouldn't really need to know much, but if you ever make a process that modifies another process, you would need to know it very well. It's usefull in debugging as well, because you will need to be able to understand it to be able to follow the flow of execution.
Topic archived. No new replies allowed.