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 / 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 |
What is a virtual destructor? Explain the use of it?
What is fflush c++?
Write a program to calculate the BMI of a person using the formula BMI = weight/height2.
Explain what you mean by a pointer.
Is c++ an integer?
What are the uses of static class data?
What is the benefit of learning c++?
What are put and get pointers?
When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
How do you print for example the integers 3,2,1,5,4 in a binary tree within the console in format where it looks like an actual binary tree?
What is linked list in c++?
What is functions syntax in c++?