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

Recommended Answers

All 4 Replies

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

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

>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?"

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.