Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the use of pointer in c++ with example?

981


What will happen if a pointer is deleted twice?

1132


Do you need a main function in c++?

1074


Is c++ an integer?

972


Is c++ primer good for beginners?

989


How many standards of c++ are there?

1050


What are the 4 types of library?

1114


Const char *p , char const *p What is the difference between the above two?

1154


Write a c program for binary addition of two 8 bit numbers.

4062


Can we use this pointer inside static member function?

1021


What are shallow and deep copies?

1068


Differentiate between the manipulator and setf( ) function?

1096


what are the iterator and generic algorithms.

1912


Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list

951


Can I create my own functions in c++?

1038