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 various arithmetic operators in c++?
Differentiate between a template class and class template in c++?
What do you mean by a template?
What is a float in c++?
Is c++ built on c?
Explain the operation of overloading of an assignment operator.
Do you know about latest advancements in C++ ?
Differentiate between late binding and early binding.
Why do we need runtime polymorphism in c++?
What are activex and ole?
What parameter does the constructor to an ofstream object take?
What is the difference between the indirection operator and the address of oper-ator?
What is binary search in c++?
Is c++ slower than c?
Explain the isa and hasa class relationships. How would you implement each?