Help with vectors

kidnly explain what this piece of code will do:
vector<vector>(1001,vector());

I don’t think this is even a valid statement because the type of elements that the vector should contain is missing.

myMap = vector<vector>(1001,vector());
here you go

note:   expected a type, got 'vector'
error: template argument 2 is invalid
error: missing template arguments before '(' token
  auto myMap = vector<vector>(1001,vector());
                                         ^

This is what the C++ compiler spits out

myMap = vector<vector>(1001,vector());

You might want to do something like this:

auto myMap = vector<vector<int>>(1001,vector<int>());
1 Like

yes its correct kindly tell what it is doing

In variable myMap, you are storing 1001 vectors of type int with default size each. :slightly_smiling_face:

2 Likes

Please format your code in future :slight_smile:

2 Likes