Why for local variables the memory required to hold the
variable is allocated from the program stack and for new
its allocated from the heap?
Answer Posted / achal ubbott
* Stack is a kind of data structure where Last In FirstOut
work. Local variables are needed for a short span of time
for immediate processing. So push and pop from stack is
used for them. Now memory is allocated to them in static
time only.
* new() operator allocates memory dynamically. Since
objects are needed for more time, space is taken from heap.
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is virtual base class?
What programming language should I learn first?
What is command line arguments in C++? What are its uses? Where we have to use this?
What are the effects after calling the delete this operator ?
What is prototype in c++ with example?
Can comments be longer than one line?
Write about the access privileges in c++ and also mention about its default access level?
What happens when you make call 'delete this;'?
What does the nocreate and noreplace flag ensure when they are used for opening a file?
Explain the extern storage classes in c++.
Is python better than c++?
Why is main an int?
Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?
Which function should be used to free the memory allocated by calloc()?
Why should you learn c++?