when I use this code:
int main()
{
unsigned int n;
cin >> n;
vector<int>number[n];
return 0;
}
the compiler marks 'n' as an error:
"expression must have a constant value"
"the value of variable 'n' cannot be used as a constant"
but when I use vector<int> v1(n)
instead, the error disappeared and worked well.
so, here is my questions:
what is the difference between defining a vector as vector<int> v1(n)
vs vector<int> v2[n]
?
Do vectors use dynamic allocation?
Thanks in advance