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
Which programming language is best to learn first?
What is a static member?
Evaluate !(1&&1||1&&0) a) Error b) False c) True
What is an inline function in c++?
What is searching?
Why do we use vector in c++?
What is the disadvantage of using a macro?
How is computer programming useful in real life?
How do you print a string on the printer?
What is difference between class and function?
Describe the advantages of operator overloading?
what is a reference variable in C++?
What is the use of 'using' declaration in c++?
an operation between an integer and real always yeilds a) integer result b) real result c) float result
Can a program run without main function?