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

Which programming language is best to learn first?

1063


What is a static member?

1040


Evaluate !(1&&1||1&&0) a) Error b) False c) True

1204


What is an inline function in c++?

1112


What is searching?

1118


Why do we use vector in c++?

1069


What is the disadvantage of using a macro?

1118


How is computer programming useful in real life?

1056


How do you print a string on the printer?

1036


What is difference between class and function?

1082


Describe the advantages of operator overloading?

1040


what is a reference variable in C++?

1235


What is the use of 'using' declaration in c++?

1133


an operation between an integer and real always yeilds a) integer result b) real result c) float result

1153


Can a program run without main function?

1156