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 various oops concepts in c++?

1017


What is the function to call to turn an ascii string into a long?

1042


What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?

1180


Is python written in c or c++?

1132


Define a pointer to a data member of the type pointer to pointer?

971


Why do we need templates?

980


What is Destructor in C++?

1175


Why is c++ so fast?

1015


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

1025


Who made c++?

1064


What is meant by a delegate?

1076


What is iterator c++?

968


How do you initialize a string in c++?

980


Why is main function important?

1093


Can java be faster than c++?

1147