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?



Why for local variables the memory required to hold the variable is allocated from the program sta..

Answer / 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

More C++ General Interview Questions

What are the manipulators in c++?

0 Answers  


What is stream and its types in c++?

0 Answers  


If all is successful, what should main return a) 0 b) 1 c) void

0 Answers  


Which software is used for c++ programming?

0 Answers  


How can I improve my c++ skills?

0 Answers  






what are the iterator and generic algorithms.

0 Answers  


What is the standard template library (stl)?

0 Answers  


Is c++ double?

0 Answers  


What is the Difference between "vector" and "array"?

15 Answers   Covansys, Gambit, TCS, Wipro,


How can an improvement in the quality of software be done by try/catch/throw?

0 Answers  


Can you please explain the difference between static and dynamic binding of functions?

0 Answers  


Is arr and &arr are same expression for an array?

0 Answers  


Categories