0

This question is not bounded to programming. It is more concerned with operational system itself.
Well, i have problem solving one profesor's question... It is constantly repeted in exam, but i can't find solution or answer as well. (The book doesn't say anything about it!)
Question goes: Why do we use memory heap to allocate classes, but not built-in types (int, char etc.)?
Please, whole generation of young programmers is counting on your help!!!

2
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by morb
0

>Why do we use memory heap to allocate classes, but not built-in types (int, char etc.)?
Bad question. Sometimes objects are better placed on the "stack", and sometimes they're better placed on the "heap". Provided the language doesn't force you into one or the other for internal reasons such as garbage collection, the answer to this question is very much dependent on context.

0

I have provided similar answer on the exam, but he said that I need to explain it better.
Perhaps You know some literature, so I could study this problem.
Thanks for reply...

0

>but he said that I need to explain it better.
Tell him to ask a better question if he wants a better answer. Or you could tell me what context he's expecting and I'll help you understand the question better. In a general context, the best answer is another question: "Why do you think we do that?"

0

He expects us to explain (heap,stack), when we use them, why we use them, why is that one better then the other etc.
I would ask him, but he is unreachable during the most part of a year. (He works as a programmer in Erricson).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.