Y would i ever want to declare a variable from heap than declaring in normal way(i dont what its called? :D) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Y would i ever want to declare a variable from heap than declaring in normal way(i dont what its called? :D)

11th Oct 2017, 10:06 AM
suryapoojary
suryapoojary - avatar
4 Answers
+ 3
variables that are defined in program statically which are normal variables not defined by New operator placed in stack memory area.
11th Oct 2017, 10:15 AM
Azam
Azam - avatar
+ 1
so if I define int a = 10 in the main function ,it will go in stack ?
11th Oct 2017, 10:13 AM
suryapoojary
suryapoojary - avatar
0
yes
11th Oct 2017, 10:11 AM
suryapoojary
suryapoojary - avatar
0
Stack is for local variables defined in a function I guess
11th Oct 2017, 10:12 AM
suryapoojary
suryapoojary - avatar