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 are the classes in c++?
Are vectors faster than arrays?
Are c and c++ different?
What is the role of C++ shorthand's?
Explain the purpose of the keyword volatile.
What is a rooted hierarchy?
How many ways can a variable be initialized into in C++?
How the virtual functions maintain the call up?
Explain the differences between list x; & list x();.
Does c++ have string data type?
What are protected members in c++?
Explain storage qualifiers in c++.
what are the events occur in intr activated on interrupt vector table
What is c++ good for?
Is facebook written in c++?