the instructor has created an array in the heap of 30 elements and then added 30 values to those elements. but this can be done in the stack as well if 30 is being provided earlier on. how does this show memory allocation during run time??
Use of new operator code skip to 6:55 for refrence
Hi @sans_sehgal, the concept of dynamic memory allocation is to reserve memory whose desired size is passed on runtime and not before that. Even if you use a stack you yourself said that 30 needs to be passed earlier, but that can be done with array as well. We can pass a constant size to array while coding but when we do not know what will be the size of array then we need to use dynamic memory allocation.
Hope this helps