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 is the use of pointer in c++ with example?
What will happen if a pointer is deleted twice?
Do you need a main function in c++?
Is c++ an integer?
Is c++ primer good for beginners?
How many standards of c++ are there?
What are the 4 types of library?
Const char *p , char const *p What is the difference between the above two?
Write a c program for binary addition of two 8 bit numbers.
Can we use this pointer inside static member function?
What are shallow and deep copies?
Differentiate between the manipulator and setf( ) function?
what are the iterator and generic algorithms.
Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list
Can I create my own functions in c++?