John Lui
John Lui

Reputation: 1464

What does this mean in vectors in c++?

vector<int> v[1000];

Is this for reserving space for the vector? But isn't the command for reserving space ()? What does this do?

Upvotes: 3

Views: 115

Answers (1)

Cory Kramer
Cory Kramer

Reputation: 118021

That is an array, with each element being a vector, so there are 1000 default-constructed (empty) vectors.

However, if you wanted to make a single vector of 1000 int, you would say

vector<int> v(1000);

Upvotes: 13

Related Questions