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 are the uses of static class data?

1130


What is the difference between a type-specific template friend class and a general template friend class?

938


Why can’t you call invariants() as the first line of your constructor?

971


What is private public protected in c++?

990


What is struct c++?

957


Can a program run without main function?

1100


What apps are written in c++?

1039


What is a literal in c++?

1029


What is flush programming?

960


If all is successful, what should main return a) 0 b) 1 c) void

977


Is it possible for the objects to read and write themselves?

1061


Do class method definitions?

988


When should we use multiple inheritance?

1002


Can I make ios apps with c++?

994


What is data abstraction? How is it different from data encapsulation?

948