Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
int a=10;


int b=new int();
b=20;


Where will b be stored,whether in heap or stack memory and why and how?
Posted
Comments
Frederick Elia 10-Jun-14 6:28am    
thank you

You have tagged your question C++ and .NET so one of the following two links should help:
C++ new[^].
C# new[^].
 
Share this answer
 
Comments
Frederick Elia 10-Jun-14 6:28am    
thank you
[no name] 11-Jun-14 9:02am    
5+.
b is stored in heap memory. Since using new operator, b allocates heap area. a is stored in stack.
Thanks.
 
Share this answer
 
v2
Comments
Frederick Elia 10-Jun-14 6:28am    
thank you
You can find some very useful and extensive info about stack and heap memory here[^]
 
Share this answer
 
Comments
Frederick Elia 10-Jun-14 6:28am    
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900