Stack vs. Heap (C++)

Started by
26 comments, last by alvaro 14 years, 10 months ago
Quote:Original post by Zahlman
Quote:And isn't the heap actually managed by malloc/free, and new/delete manage the "free store"?


Yes. Most people can't be bothered to distinguish, though. Although they should.

What is the difference again?

Quote:The question was over how initializer lists should be employed. That was all that needed to be said -- "look up something called initializer lists". KulSeran did a nice job of it. I thank you for your help though, and your efforts to make me feel like a dumbass are truly appreciated.

Given you asked about stack and heap, given you titled your thread about stack and heap, given you kept talking about stack and heap, that is what you got. No need to be snippy, we are just trying to help.
Advertisement
Quote:Original post by alvaro
Quote:Original post by argonaut
Quote:Original post by alvaro

Now, if you have questions about any of the three issues above (stack-vs-heap, initializer lists and passing by value or by reference), try to not mix them up in your question.


The question was over how initializer lists should be employed. That was all that needed to be said -- "look up something called initializer lists". KulSeran did a nice job of it. I thank you for your help though, and your efforts to make me feel like a dumbass are truly appreciated.


That was not the idea at all, and I am sorry if it came through as insulting. Lack of knowledge doesn't make you a dumb ass. I wrote my post hoping that it would help you structure your language and your thoughts about programming.

Your reply was polite and informative. I wouldn't worry about it.
Quote:Original post by _Sigma
Quote:Original post by Zahlman
Quote:And isn't the heap actually managed by malloc/free, and new/delete manage the "free store"?

Yes. Most people can't be bothered to distinguish, though. Although they should.

What is the difference again?


There are three kinds of storage in the C++ memory model: static, automatic, and free store. There is no such thing as "the stack" or "the heap", although automatic storage is frequently implemented using a stack, and the free store is often referred to as "the heap" although rarely is a heap data structure used in its implemtation.

It's pretty important that a C++ programmer know and understand the difference between the three types of storage and the various pitfalls associated with each.

Stephen M. Webb
Professional Free Software Developer

Quote:Original post by _Sigma
Quote:Original post by Zahlman
Quote:And isn't the heap actually managed by malloc/free, and new/delete manage the "free store"?


Yes. Most people can't be bothered to distinguish, though. Although they should.

What is the difference again?


Abstraction.
new/delete are using "the free store", and you don't know how it's implemented. Maybe with "the heap", maybe not.
English is not my native language.Sam.
Bregma, rolkA: Thanks. I figured I knew it, but decided to sanity check just in case :)

Quote:and the free store is often referred to as "the heap" although rarely is a heap data structure used in its implemtation.

I didn't know that one tidbit.
Quote:Original post by argonaut
Thank you for your answer Oberon, but apparently there is a difference, since I keep getting yelled at for it.


Then you need to make sure that the people yelling at you (and I hope you didn't mean yelling in a literal sense) sit down with you and explain exactly what the problem is, and how you can stop them 'yelling' at you.

And don't let them leave until you understand, it's the only way you will get this resolved, as having a very quick glance over this thread, there does seem to be some confusion on your side over exactly what you're doing 'wrong'.

And if they cannot explain it to you to the point where you understand it, then it could be the people who are responsible for mentoring you that are not up to doing the job.

Quote:Original post by alvaro
Quote:Original post by argonaut
Quote:Original post by alvaro

Now, if you have questions about any of the three issues above (stack-vs-heap, initializer lists and passing by value or by reference), try to not mix them up in your question.


The question was over how initializer lists should be employed. That was all that needed to be said -- "look up something called initializer lists". KulSeran did a nice job of it. I thank you for your help though, and your efforts to make me feel like a dumbass are truly appreciated.


That was not the idea at all, and I am sorry if it came through as insulting. Lack of knowledge doesn't make you a dumb ass. I wrote my post hoping that it would help you structure your language and your thoughts about programming.


I'm the one who is to be sorry. I apologize for the rude comment that I made and I understand that you were only trying to help. The situation has gotten me roughed up a bit, but that is not an excuse. Please accept my sincere gratitude for your help.
~Argonaut________________________________Why "~Argonaut"? It's all just a mathematical expression denoting a close approximation of "Argonaut", which is irrational and can't be precisely defined.
Quote:Original post by argonaut
I'm the one who is to be sorry. I apologize for the rude comment that I made and I understand that you were only trying to help. The situation has gotten me roughed up a bit, but that is not an excuse. Please accept my sincere gratitude for your help.

We're cool. :)

This topic is closed to new replies.

Advertisement