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 classes in c++?

1156


Are vectors faster than arrays?

1051


Are c and c++ different?

1029


What is the role of C++ shorthand's?

1318


Explain the purpose of the keyword volatile.

1240


What is a rooted hierarchy?

1216


How many ways can a variable be initialized into in C++?

1064


How the virtual functions maintain the call up?

1283


Explain the differences between list x; & list x();.

1060


Does c++ have string data type?

1163


What are protected members in c++?

1178


Explain storage qualifiers in c++.

1132


what are the events occur in intr activated on interrupt vector table

1799


What is c++ good for?

1115


Is facebook written in c++?

1051