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

1129


Differentiate between a template class and class template in c++?

1101


What do you mean by a template?

1067


What is a float in c++?

985


Is c++ built on c?

1035


Explain the operation of overloading of an assignment operator.

1173


Do you know about latest advancements in C++ ?

1249


Differentiate between late binding and early binding.

1279


Why do we need runtime polymorphism in c++?

1026


What are activex and ole?

1059


What parameter does the constructor to an ofstream object take?

1058


What is the difference between the indirection operator and the address of oper-ator?

1120


What is binary search in c++?

1033


Is c++ slower than c?

1038


Explain the isa and hasa class relationships. How would you implement each?

1132