I read on GeeksforGeeks that arrays in c++ are statically allocated memory i.e. at the compile time.
Whereas Vectors in C++ are allocated memory dynamically.
E.g. vector vec;
vec.push_back(1);
But I have some doubt in this.
Like if I declare array like :->
int n;
cin>>n;
int arr[n];
How can this be statically allocated because at runtime only we will provide the value for n and then only memory will get allocated. Shouldn’t this come under dynamic allocation?
I might be asking very silly question but I couldn’t find any good explanation on net.
Thx in advance.! 