when we can store data of single datatype in array then why do we need to create array by using vector?
as we know that array and vector are same. and what is the benefit of dynamic memory? because in this lecture prateek sir told that when we create an array using vector it will occupy the dynamic memory. why do we need to store data in dynamic memory? we can store data using array in static memory and static memory get free when one operation is executed (as we have learned in stack)…
What is vector?
the problem is that stack memory is limited and small so there is a limit for how much memory you can assign for an array , while dynammic memory is allocated from heap and heap size is much much bigger than stack size , so you can create larger size vector as compared to array . also vector will handle the allocation and deallocation of memory by itself